Inventor Customization

Inventor Customization

Reply
Valued Mentor
stephengibson76
Posts: 1,093
Registered: ‎08-01-2006
Message 1 of 6 (503 Views)

ilogic, insert sketched symbol from another idw

503 Views, 5 Replies
06-21-2011 07:33 AM

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


Mentor
matt_jlt
Posts: 216
Registered: ‎07-28-2007
Message 2 of 6 (499 Views)

Re: ilogic, insert sketched symbol from another idw

06-21-2011 07:09 PM 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 :smileyhappy:

Regards, Matt.

Valued Mentor
stephengibson76
Posts: 1,093
Registered: ‎08-01-2006
Message 3 of 6 (491 Views)

Re: ilogic, insert sketched symbol from another idw

06-23-2011 12:44 AM 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


Employee
RobertStein
Posts: 2
Registered: ‎06-07-2010
Message 4 of 6 (480 Views)

Re: ilogic, insert sketched symbol from another idw

06-23-2011 04:51 AM in reply to: stephengibson76

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

 



Robert Stein
Technical Consultant
Global Services, Amer Project Delivery Team
Autodesk, Inc.
Valued Mentor
stephengibson76
Posts: 1,093
Registered: ‎08-01-2006
Message 5 of 6 (475 Views)

Re: ilogic, insert sketched symbol from another idw

06-23-2011 06:44 AM in reply to: RobertStein

thankyou, I will give it a try next week

Stephen Gibson



View stephen gibson's profile on LinkedIn


Valued Mentor
stephengibson76
Posts: 1,093
Registered: ‎08-01-2006
Message 6 of 6 (453 Views)

Re: ilogic, insert sketched symbol from another idw

07-06-2011 01:43 AM in reply to: stephengibson76

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


Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.