iLogic Rule To Insert Connector Symbol Base on Parts List

iLogic Rule To Insert Connector Symbol Base on Parts List

Chirpyboy2060647
Advocate Advocate
866 Views
8 Replies
Message 1 of 9

iLogic Rule To Insert Connector Symbol Base on Parts List

Chirpyboy2060647
Advocate
Advocate

Hi All,

Im looking to make a rule that would take from my BOM/Parts List. When 901 2025 0132 POM part shows up, I want to have it then insert the corresponding Connector Symbol on an IDW. Just looking for some guidance as i love figuring out iLogic code. I attached a picture to kind of give the idea of what i want to accomplish.

 

Thanks! 

0 Likes
Accepted solutions (1)
867 Views
8 Replies
Replies (8)
Message 2 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@Chirpyboy2060647,

 

Can you please provide sample drawing with connected symbols to try ? please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

Chirpyboy2060647
Advocate
Advocate

@chandra.shekar.g I attached a simple connector with the default TB. Also added the icon and a bom, but to reiterate, looking to make a script where when my BOM is published i can run my rule, then it will input all the corresponding. I had it working to a point, but corrupted save and couldnt figure out how to get it to place it with the prompted entry. 

 

Side note: I also plan to have the sketch symbols auto populate the qty based on the BOM. 

 

Found the code that i was working off of as a start. Sadly my file i was working on got corrupted during its save. 

 

'Sub Main() 
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
 
' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition _
       = oDrawDoc.SketchedSymbolDefinitions.Item("SymbolA") 'this changes to the BeMatrix Part
 
Dim oDrawDoc As DrawingDocument = ThisDoc.Document 
 
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(10, 10)
 
' Add an instance of the sketched symbol definition to the sheet.
' Rotate angle = 0 radians,
' scale = 1 when adding
' no prompt text
Dim oSketchedSymbol As SketchedSymbol _
       = oSheet.SketchedSymbols.Add( _
             oSketchedSymbolDef, _
             oInsertionPoint, _
             0, 1, Nothing) 'Getting hung up here on what to put for "Nothing" to prompt the entry.
'End Sub

 

0 Likes
Message 4 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@Chirpyboy2060647,

 

Sorry for late reply,

 

Try below iLogic code to insert sketch symbols.

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition
oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("Legend - (MDC) Manual Double Connector")

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

' This sketched symbol definition contains one prompted string input. An array
' must be input that contains the strings for the prompted strings.
Dim sPromptStrings(0) As String
sPromptStrings(0) = "3" 'This string which will be added under "Qty". It can be 1, 2, 3 etc.,

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry

' Add an instance of the sketched symbol definition to the sheet.
' Rotate the instance by 45 degrees and scale by .75 when adding.
' The symbol will be inserted at (0,0) on the sheet. Since the
' start point of the line was marked as the insertion point, the
' start point should end up at (0,0).
Dim oSketchedSymbol As SketchedSymbol
oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oTG.CreatePoint2d(10, 10), 0, 1, sPromptStrings)
 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@Chirpyboy2060647,

 

Try below iLogic code to get Qty (2nd Column) of first row from BOM.

Sub Main ()  
	' Get a reference to the active drawing document.
	Dim oDrawDoc As DrawingDocument
	 oDrawDoc = ThisApplication.ActiveDocument 
	 
	Dim oSymDef As SketchedSymbolDefinition
	oSymDef = oDrawDoc.SketchedSymbolDefinitions.Item("Legend - (MDC) Manual Double Connector")

	' Get a reference to the active sheet.
	Dim oSheet As Sheet
	 oSheet = oDrawDoc.ActiveSheet
	 
	 Dim oPartsList As PartsList
	 oPartsList = oSheet.PartsLists.Item(1)
	 
	 Excel_Qty = oPartsList.PartsListRows.Item(1).Item(2).Value 'Here oPartsList.PartsListRows.Item(1) indicates 1st row of BOM and oPartsList.PartsListRows.Item(1).Item(2) indicates 2nd column of BOM i.e, 'Qty' column.
	 
	' Create an array that has the input for the prompted text.
	Dim astrPrompts(1) As String
	astrPrompts(0) = Excel_Qty

	astrPrompts(1) = ""

	' Place the symbol. This places it relative to the first view on the'sheet.' This could be any drawing view, but for this sample it just uses the'first.
	Dim oView As DrawingView
	 oView = oSheet.DrawingViews.Item(1)

	' Compute the position.
	Dim oPosition As Point2d
	 oPosition = oView.Center
	oPosition.Y = oPosition.Y - (oView.Height / 2 + 0.5)

	' Place the symbol.
	Dim oSymbol As SketchedSymbol
	 oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,astrPrompts)
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 9

Chirpyboy2060647
Advocate
Advocate

@chandra.shekar.g Awesome I'll give this a try. I've gone back to some basics and starting some Class Diagrams to figure out my projects. Thanks as always for your help with mind and others :). Im in the process of learning VBA for Excel which from all i see will be extremely beneficial to Inventor iLogic. 

0 Likes
Message 7 of 9

Chirpyboy2060647
Advocate
Advocate

@chandra.shekar.gSo do you know if theres a simpler way or a way if say i have....10-15 sketch symbols that would be used on any given project. Or do i just have to make a bunch of Dims for them all. 🙂 I havent been able to delve into 2019 yet but im figuring they havn't added the API for that yet.

0 Likes
Message 8 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@Chirpyboy2060647

 



Or do i just have to make a bunch of Dims for them all.

 I am not clear about your question. Can you please elaborate on above statement?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 9 of 9

Chirpyboy2060647
Advocate
Advocate

Hey im sorry for late response, ha.

 

Also what a bad sentence i wrote. 

Dim oSymDef As SketchedSymbolDefinition
	oSymDef = oDrawDoc.SketchedSymbolDefinitions.Item("Legend - (MDC) Manual Double Connector")

So i have this line of code for just 1 sketch symbol. If i have 20-30 i want to have to check do i need just make new lines of code for each sketch symbol or can i add to this for the rest . 

0 Likes