Hi @A.Acheson ,
This is the code for the sketch symbols i was trying to use (it is from the forums, though it was used for textbox notes, but i thought i could make it work) should say that the sketch symbol is only a picture i inserted, the array section is unedited here. But it gives me,
"Error on line 60 in rule: SketchArray, in document: bp_test001.dwg
Object reference not set to an instance of an object."
And aborts, placing the symbols ontop each other. My first thought was that something is wrong with the declaration, and i tested to add a textbox, but same error. Then i read about it "null reference" so i guess im mssing some logic here.
Sub Main
'[ Set the Symbols To work With. They must be in the Library
Names.add("ham2")
Names.add("ham3")
Names.add("test1")
Names.add("test2")
Dim Selection As String
Do
Selection = InputListBox("Prompt", Names, d0, Title := "Title", ListName := "List")
If Len(Selection)<> 0 Then
Notes.add(Selection)
End If
Loop While Len(Selection)>0
']
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument ' a reference to the drawing document.
Dim oSketchSymLib As SketchedSymbolDefinitionLibrary'Getting Symbol from library ......\Design Data\Symbol Library\
oSketchSymLib = oDrawDoc.SketchedSymbolDefinitions.SketchedSymbolDefinitionLibraries.Item("Library")
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Dim oSketchedSymbol As SketchedSymbol
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Notes.Reverse 'Reverse list to add first items selected last
For Each Name In Notes 'Loop through collection and add symbol to drawing
oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.AddFromLibrary(oSketchSymLib, Name , True)'Add the Sketched Symbol from the library to local symbols before you can place it.
Dim oTGPoint As Point2d
oTGPoint = oTG.CreatePoint2d(0, 0)
oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oTGPoint)' Add an instance of the sketched symbol definition to the sheet.
Next
MoveNote(oDrawDoc, oSheet, oTG)
End Sub
Dim Names As New ArrayList
Dim Notes As New ArrayList
Dim Name As String
Sub MoveNote(oDrawDoc As DrawingDocument,oSht As Sheet,oTG As TransientGeometry)
For Each Name In Notes
For Each sym As SketchedSymbol In oSht.SketchedSymbols'Loop through each symbol to identify object
If Name = sym.Name Then
Dim LSCX, LSCY As Double
LSCX = oSht.Border.RangeBox.MinPoint.X'Left Sheet Corner
LSCY =oSht.Border.RangeBox.MinPoint.Y'Left Sheet Corner
Dim oTextBox As Inventor.TextBox
oTextBox = sym.Definition.Sketch.TextBoxes(1)
Dim TextWidth, TextHeight As Double
TextWidth = oTextBox.RangeBox.MaxPoint.X - oTextBox.RangeBox.MinPoint.X
TextHeight = oTextBox.RangeBox.MaxPoint.Y - oTextBox.RangeBox.MinPoint.Y
Dim oSpace As Double'give some space between symbols
oSpace = 0.3
Dim NewHeight As Double 'Stack the symbols starting from bottom
NewHeight = (TextHeight) + NewHeight + oSpace
Dim oTGPoint As Point2d
oTGPoint = oTG.CreatePoint2d(LSCX+TextWidth/2+oSpace, LSCY+NewHeight)
sym.Position = oTGPoint
End If
Next
Next
End Sub
And for the ballooning part, i haven't started digging in it yet