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
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
Regards, Matt.
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?
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
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
Can't find what you're looking for? Ask the community or share your knowledge.