iLOGIC Insert Sketched Symbols

iLOGIC Insert Sketched Symbols

Anonymous
Not applicable
4,008 Views
24 Replies
Message 1 of 25

iLOGIC Insert Sketched Symbols

Anonymous
Not applicable
I'm wondering if there is a way to automatically insert sketch symbols into views using iLOGIC? I would like to create 2 criteria. I would like to insert a symbol on the "ORIGIN" of each view on the page. I would like to insert a symbol on the "COG" of each view on the page. My desired symbol is located here: "Drawing Resources, Sketched Symbols, Stamps & Symbols, COG / Datum" Thanks
0 Likes
4,009 Views
24 Replies
Replies (24)
Message 21 of 25

gleocata
Contributor
Contributor

 

Hi everyone,
i have a problem and i hope someone can help me,
I use an ilogic rule to insert a sketch symbol in a certain position, and it works but only if I choose the symbol, I would like to remove the choice and insert the symbol directly, can anyone help me?
Thank you all

Dim strStampList As New ArrayList
strStampRequired = True
strStampList.Add("My symbol")

strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")

Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim oSymbolName As String
oSymbolName = "My symbol"

Dim SourceFile As String = "N:\Inventor 2022\Design Data\Symbol Library\Simboli.idw"
Dim strSourceIDW As DrawingDocument
strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
Dim symbolDef As SketchedSymbolDefinition
For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
strStampList.Add(symbolDef.Name)
Next
'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
End If
Next
strSourceIDW.Close()
'End If



Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
 
' Obtain a reference to the desired sketched symbol definition.
'Dim oSketchedSymbolDef As SketchedSymbolDefinition _
'       = oDrawDoc.SketchedSymbolDefinitions.Item("Nome file + percorso")
'Dim oSymbolName As String
oSymbolName = "My symbol"
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
 'get the symbol definition to use
Dim oSketchedSymbolDef As SketchedSymbolDefinition
oSketchedSymbolDef = oDoc.SketchedSymbolDefinitions.Item(oSymbolName)
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(3, 0.5)
 
' 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)

 

 

0 Likes
Message 22 of 25

A.Acheson
Mentor
Mentor

There is two string variable names identifying the symbol name. strSelectedStamp & oSymbolName

 

At the moment strSelectedStampis used to set the symbol to be retrieved from the symbol library. In the drawing another oSymbolName is setting the symbol to be place in the drawing  

You can combine these two into 1 and use this where needed.

Example set String to static like this

oSymbolName = "My Symbol"

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

gleocata
Contributor
Contributor

thanks for your suggestion, but I'm not a programmer, I found this rule already made and I would like to adapt it.
I tried to follow your instructions but it doesn't work.
If I post the code, can you tell me where I'm wrong?

'Dim strStampList As New ArrayList
'strStampRequired = True
'strStampList.Add("Nome file + percorso")

'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")

Dim strDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
Dim oSymbolName As String
oSymbolName = "Nome file + percorso"

Dim SourceFile As String = "N:\Settaggi Inventor\Inventor 2022\Design Data\Symbol Library\Simboli MIX.idw"
Dim strSourceIDW As DrawingDocument
strSourceIDW = ThisApplication.Documents.Open(SourceFile, False)
Dim symbolDef As SketchedSymbolDefinition
'For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
'strStampList.Add(symbolDef.Name)
'Next
'strSelectedStamp = InputListBox("Please select a stamp.", strStampList, strSelectedStamp, "Stamp Selection", "Available Stamps")
'For Each symbolDef In strSourceIDW.SketchedSymbolDefinitions
'If (StrComp(symbolDef.Name, strSelectedStamp, vbTextCompare) = 0) Then
'CopyFrom = symbolDef.CopyTo(strDrawDoc, True)
'End If
'Next
'strSourceIDW.Close()
'End If



Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
 
' Obtain a reference to the desired sketched symbol definition.
'Dim oSketchedSymbolDef As SketchedSymbolDefinition _
'       = oDrawDoc.SketchedSymbolDefinitions.Item(oSymbolName)
'Dim oSymbolName As String
oSymbolName = "Nome file + percorso"
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
 'get the symbol definition to use
Dim oSketchedSymbolDef As SketchedSymbolDefinition
'oSketchedSymbolDef = oDoc.SketchedSymbolDefinitions.Item("Nome file + percorso")
oSketchedSymbolDef = oDoc.SketchedSymbolDefinitions.Item(oSymbolName)
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
'create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(3, 0.5)
 
' 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)
0 Likes
Message 24 of 25

A.Acheson
Mentor
Mentor

So the code lines to retrieve the symbol from the symbol library have been switched off. If that is where the symbol is stored you will still need those code lines so make them active. You will need to change the string variable name also. Code below has been changed and shortened. 

 

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument

Dim oSymbolName As String = "Nome file + percorso"
Dim SourceFile As String = "N:\Settaggi Inventor\Inventor 2022\Design Data\Symbol Library\Simboli MIX.idw"

Dim strSourceIDW As DrawingDocument = ThisApplication.Documents.Open(SourceFile, False)

For Each symbolDef As SketchedSymbolDefinition In strSourceIDW.SketchedSymbolDefinitions
      If (StrComp(symbolDef.Name,  oSymbolName, vbTextCompare) = 0) Then
        CopyFrom = symbolDef.CopyTo(oDrawDoc, True)
      End If
Next

strSourceIDW.Close()

' Obtain a reference to the desired sketched symbol definition.
Dim oSketchedSymbolDef As SketchedSymbolDefinition = oDrawDoc.SketchedSymbolDefinitions.Item(oSymbolName)

Dim oSheet As Sheet = oDrawDoc.ActiveSheet
 
' Create insertion point, coordinates - in cm !
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oInsertionPoint As Point2d = oTG.CreatePoint2d(3, 0.5)
 
' Symbol Add Instructions.
' Symbol definition, Insertion Point, Rotate angle = 0 radians, scale = 1 when adding, no prompt text

Dim oSketchedSymbol As SketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef,oInsertionPoint, 0, 1, Nothing)

 

 

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

gleocata
Contributor
Contributor

Thank you very much
amazing work!

solution accepted

 

I don't see the button solution accepted  , but it is to be considered accepted.