Inserts more sketch symbols to drawing via iLogic

Inserts more sketch symbols to drawing via iLogic

hulemartin92
Participant Participant
1,842 Views
7 Replies
Message 1 of 8

Inserts more sketch symbols to drawing via iLogic

hulemartin92
Participant
Participant

Hello all,

 

is there some possiblity how to insert more then one sketch symbol to the drawing by iLogic on the dedicated place?

Respectively, we have our Library of the sketch symbols and for each drawing we need use other symbols. Could be possible made a form with name of our symbols with the check boxes and if I check one, two, ..., ten symbols so it appears on the drawing. I know that it ispossible but I need that the symbols are inserted on the top of each other in predefined places, always from the bottom up and it must not matter whether I click on the second, fourth and tenth symbol or the first, second and third symbol.

 

I don't know If I specified my requeset meaningful, but Thank you so much to all for your time.

 

Martin.

0 Likes
1,843 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor

Yes this is possible but the display of the form as you describe of boolean multiple select will only be possible as VBA form, windows form or looping of array listbox.  An ilogic form  cannot perform the symbol display as you describe. An alternate form is to display list array of symbol names in a  listbox in a loop allowing one symbol selection. Are you familiar with vba forms or would the listbox suit your need? 

 

Once each symbol is placed the location will need to be changed. 

 

Vba API help sample is here.  If you currently use ilogic code please post here for help adapting. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 8

hulemartin92
Participant
Participant

Hi,

No I have not any expirience with VBA form, but maybe is there easier way to solved this problem with create the "Symbols" because our symbols are only the predefined text (Heat treat, Machine, Varnish RAL XXXX, etc...) could be possible make a form with this our texts and check boxes and if I check eatch "text" then would enrolled over the Title block? But again we need make this notes independent of the order and must be written on top of each other.

 

Thank you!

0 Likes
Message 4 of 8

A.Acheson
Mentor
Mentor

Can you attach or show images of what makes up your typical Notes section of the drawing. Are they currently general text or symbols containing general text?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 8

hulemartin92
Participant
Participant

Hi,

It is in the Czech Language, but this is our typical notes but it is not necessary that they be 3, can be only 1or 4 or 10, it is part by part. Total we have 10 typical notes, one total custome, and two which we sometimes edditing, for exampl "Varnish by RAL XXXX" there we allways write RAL number

 

hulemartin92_0-1642574355632.png

 

0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

The below rule is the simplest that  I can think of to establish a working rule. This will place symbols from a looping list and then stack them on top of each other. The symbols must contain text boxes and must be in the drawing.

AAcheson_0-1642986471984.pngAAcheson_1-1642986507779.png

 

 Sub Main
	
	'[ Set the Symbols To work With. They must be In the drawing
	Names.add("Note1")
	Names.add("Note2")
	Names.add("Note3")
			
	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 oSketchedSymbolDef As SketchedSymbolDefinition
	
	Dim oSketchedSymbol As SketchedSymbol
	
    Dim oDrawDoc As DrawingDocument'This assumes a drawing document is active.
    oDrawDoc = ThisApplication.ActiveDocument '  a reference to the drawing document.
    
	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.Item(Name)' Obtain a reference to the desired sketched symbol definition.
		
		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

Other methods using ilogic would be to create a boolean form in the symbols library, create a list , assign it to a global variable then go back to the drawing and retrieve this list  and place the symbols based on this list.  The main reason to use the global variables is to avoid having to create parameters in each drawing in order to launch the ilogic form. This is more complex and maybe not a viable solution.

AAcheson_2-1642986700218.png

 

Another method still and likely the best functional solution  is to create a VBA form, add the symbols names from the library then retrieve the symbols from the library and place on the Drawing. 

AAcheson_3-1642988010409.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 8

hulemartin92
Participant
Participant

Hi Mr. Acheson,

 

It look super but it will be possible connect this code with the model data? For example if I made the part and in the form from this part I will select some information (for example - Heat treat, Machine, Varnish RAL XXXX, etc...) I want see all this selected information in the drawing. Is it possible?

 

Thank you!

0 Likes
Message 8 of 8

A.Acheson
Mentor
Mentor

You can place the linked property set in the text inside the symbol. When the symbol is placed the first view will be referenced for retrieval of model iproperties. 

AAcheson_0-1643386528285.png

And here is an update to the rule to get the symbol from the library instead of having it saved in the drawing to begin with. 

 

AAcheson_1-1643387030207.png

Sub Main
	
	'[ Set the Symbols To work With. They must be in the Library
	Names.add("Note1")
	Names.add("Note2")
	Names.add("Note3")
			
	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
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes