Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic, insert sketched symbol from another idw

5 REPLIES 5
Reply
Message 1 of 6
stephengibson76
1015 Views, 5 Replies

ilogic, insert sketched symbol from another idw

I dont want to bloat my template idw with a load of sketched symbols.  

 

What I would like is an ilogic rule that I can pull up a form, select a sketched symbol from a list, inventor will then automatically open another idw containing all of the symbols, then copy the selected and paste into my current idw, then close the sketched symbol idw.

 

effectivly what I would like to do is the same as using wblocks in autocad

Stephen Gibson



View stephen gibson's profile on LinkedIn


5 REPLIES 5
Message 2 of 6
matt_jlt
in reply to: stephengibson76

You would have to use VB with the iLogic as iLogic code on it's own has limited capabilities.

 

Is there any reason it has to be iLogic? This would be much easier as a seperate VBA Macro / VB.Net Addin as you could just have it on the toolbar. Just a Thought Smiley Happy

Regards, Matt.

Message 3 of 6
stephengibson76
in reply to: matt_jlt

no reason it has to be ilogic, other than I can probably work out whats going on.  can anyone do me some VB that will do the job?

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 4 of 6

Here is some sample code a friend wrote for me. Copy and paste it into a VBA macro and tweak whatever you need.

 

Function CopyFrom(otherDrawingName As String, symbolName As String, thisDrawingDoc As DrawingDocument) As SketchedSymbolDefinition

On Error GoTo CannotOpen

Dim otherDrawing As DrawingDocument

Set otherDrawing = ThisApplication.Documents.Open(otherDrawingName, False)

 

Set CopyFrom = Nothing

Dim symbolDef As SketchedSymbolDefinition

For Each symbolDef In otherDrawing.SketchedSymbolDefinitions

   If (StrComp(symbolDef.Name, symbolName, vbTextCompare) = 0) Then

     Set CopyFrom = symbolDef.CopyTo(thisDrawingDoc, ReplaceExisting:=True)

   End If

Next

 

otherDrawing.ReleaseReference

 

If (CopyFrom Is Nothing) Then

   Call MsgBox("Cannot find a sketched symbol named " & symbolName & " in the file " & otherDrawingName, vbOKOnly, "Sketched Symbol Copy")

End If

Exit Function

CannotOpen:

Call MsgBox("Cannot find (or open) a file named: " & otherDrawingName)

End Function

 

Sub Test()

  Dim sourceName As String

  sourceName = "C:\inv-dev2\parts2011g\SketchedSymbolCopy\SymbolSourceA.idw"

  Dim symbolName As String

  symbolName = "Dowel"

 

  Dim symbolDef As SketchedSymbolDefinition

  Set symbolDef = CopyFrom(sourceName, symbolName, ThisApplication.ActiveDocument)

 

   Dim oSheet As Sheet

   Set oSheet = ThisApplication.ActiveDocument.ActiveSheet

 

  ' Test adding it to the drawing:

    Dim oTG As TransientGeometry

    Set oTG = ThisApplication.TransientGeometry

    Dim oSketchedSymbol As SketchedSymbol

    Set oSketchedSymbol = oSheet.SketchedSymbols.Add(symbolDef, oTG.CreatePoint2d(5, 5), 0#, 0.75)

End Sub

 

Thanks

Rob Stein

Real Software Solutions

robert.stein@yourrealsoftwaresolutions.com

 


Rob Stein

Senior Product Owner, Fusion Data Management



Message 5 of 6

thankyou, I will give it a try next week

Stephen Gibson



View stephen gibson's profile on LinkedIn


Message 6 of 6

Thanks, I got it working to bring in a specific symbol.  What I would like is a list of symbols that I can choose which one to bring into my idw

Stephen Gibson



View stephen gibson's profile on LinkedIn


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report