Inventor Customization

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

ilogic, insert sketched symbol from another idw

452 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
Posts: 199
Registered: ‎07-28-2007
Message 2 of 6 (448 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,064
Registered: ‎08-01-2006
Message 3 of 6 (440 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 (429 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,064
Registered: ‎08-01-2006
Message 5 of 6 (424 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,064
Registered: ‎08-01-2006
Message 6 of 6 (402 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


You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube