Transfering Sketched Symbols to new drawing

Transfering Sketched Symbols to new drawing

Anonymous
Not applicable
1,683 Views
23 Replies
Message 1 of 24

Transfering Sketched Symbols to new drawing

Anonymous
Not applicable

I haven't done much programming at all in the last 10 years, so I am probably missing something simple here, but I don't understand why this is failing on the AddChild call

 

Any help appreciated. 

Public Sub Test_SketchedSyms()

    Dim oDestinationdoc As DrawingDocument
    Set oDestinationdoc = ThisApplication.ActiveDocument

    Dim oSourceDoc As DrawingDocument
    Set oSourceDoc = ThisApplication.Documents.Open("C:\Test.idw", False)
    
    Dim oSketchSymNodes As ObjectCollection
    Set oSketchSymNodes = ThisApplication.TransientObjects.CreateObjectCollection

    Dim oSourcePane As BrowserPane
    Set oSourcePane = oSourceDoc.BrowserPanes.ActivePane
    
    Dim oDestinationPane As BrowserPane
    Set oDestinationPane = oDestinationdoc.BrowserPanes.ActivePane

    Dim oSourceSketchSyms As BrowserNode
    Set oSourceSketchSyms = oSourcePane.TopNode.BrowserNodes("Drawing Resources").BrowserNodes.Item("Sketch Symbols")
    
    Dim oDestinationSketchSyms As BrowserNode
    Set oDestinationSketchSyms = oDestinationPane.TopNode.BrowserNodes("Drawing Resources").BrowserNodes.Item("Sketch Symbols")

    Dim oBrowserNode As BrowserNode
    For Each oBrowserNode In oSourceSketchSyms.BrowserNodes
        Debug.Print oBrowserNode.FullPath
        oSketchSymNodes.Add oBrowserNode
        
    Next
    Dim oNode As BrowserNode

    For Each oNode In oSketchSymNodes
        oDestinationSketchSyms.AddChild oNode
    Next

End Sub

0 Likes
Accepted solutions (1)
1,684 Views
23 Replies
Replies (23)
Message 21 of 24

Anonymous
Not applicable

image.png

0 Likes
Message 22 of 24

Frederick_Law
Mentor
Mentor

Those are not Folder in the browser.  They're folder in the Symbol Library.

0 Likes
Message 23 of 24

marcin_otręba
Advisor
Advisor

i wanted to write that you can add node to select set and execute copy command, then select top node in dest file and execute paste but here you have solution...

 

https://forums.autodesk.com/t5/inventor-customization/copy-sketched-symbols-with-folders/td-p/713142...

 

 

 oh and one more think i use symbol library... this is the best way.

 

and you can copy all froim library using:

 

SketchedSymbolDefinitions.AddFromLibrary MethodSketchedSymbolDefinitions.AddFromLibrary( SketchedSymbolDefinitionLibrary As Variant, SketchedSymbolDefinitionName As String, [ReplaceExisting] As Variant ) As SketchedSymbolDefinition

 

only set ReplaceExisting as true

 

but it will NOT recreate folder structure from library...

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 24 of 24

Anonymous
Not applicable
Accepted solution

Right or wrong, this is what I ended up with.    I had tried working with the code from the other post, but it dealt with only sketched symbols already in the drawing, not copying them from one drawing to another, with folders intact.  Best I can figure that isn't possible.  The sketched symbols have to already be in the sketched symbol folder, before they can be added to a sub folder, they can't be brought from the template file as a object collection and put into a new folder in the sketched symbols folder directly.  

 

Note, the code below is used after I bring the sketched symbols from the Template using the CopyTo method. 

 


Private Sub SketchedSyms() Dim oPane As BrowserPane Set oPane = odoc.BrowserPanes.ActivePane Dim oSketchSyms As BrowserNode Set oSketchSyms = oPane.TopNode.BrowserNodes("Drawing Resources").BrowserNodes.Item("Sketch Symbols") Dim oSketchObjs As ObjectCollection Set oSketchObjs = ThisApplication.TransientObjects.CreateObjectCollection Dim oSketchNode As BrowserNode Dim oCallouts As ObjectCollection Set oCallouts = ThisApplication.TransientObjects.CreateObjectCollection Dim oNotes As ObjectCollection Set oNotes = ThisApplication.TransientObjects.CreateObjectCollection Dim oWatermarks As ObjectCollection Set oWatermarks = ThisApplication.TransientObjects.CreateObjectCollection Dim oTemplate As ObjectCollection Set oTemplate = ThisApplication.TransientObjects.CreateObjectCollection Dim oTables As ObjectCollection Set oTables = ThisApplication.TransientObjects.CreateObjectCollection Dim oCoatings As ObjectCollection Set oCoatings = ThisApplication.TransientObjects.CreateObjectCollection For Each oSketchNode In oSketchSyms.BrowserNodes Dim oLabel As String oLabel = oSketchNode.BrowserNodeDefinition.Label Select Case oLabel Case "Machined From", "Note", "Note Frame" oCallouts.Add oSketchNode Case "Add Custom Note", "Apply Thread Locker", "Bolt Length Tolerance", "Engrave as Shown", "GP Arrangement", "GP Configuration", "Machine From", "Model Comments", "Mold Machined From Solid Model", "Molded Parts Note", "Remove Burrs & Sharp Edges", "Stamp Molds Note (all mold dwgs)", "Stamp Molds Note (Electrical Eng)", "Stamp Parts", "Verify OD and Circumference" oNotes.Add oSketchNode Case "Revert to Previous Revision" oWatermarks.Add oSketchNode Case "Notes Header", "Remove Burr & Sharp Edges Auto", "Stamp Parts Auto" oTemplate.Add oSketchNode Case "Defect Info" oTables.Add oSketchNode Case "Coating, Custom", "Coating, Hard Anodize", "Material, E-2748A Epoxy" oCoatings.Add oSketchNode End Select Next Dim oBrowserfolder As BrowserFolder Dim oNode As BrowserNode On Error Resume Next Set oBrowserfolder = oSketchSyms.BrowserFolders("Call Outs") If Err Then Call oPane.AddBrowserFolder("Call Outs", oCallouts) Err.Clear Else For Each oNode In oCallouts oBrowserfolder.Add oNode Next End If Set oBrowserfolder = oSketchSyms.BrowserFolders("Notes") If Err Then Call oPane.AddBrowserFolder("Notes", oNotes) Err.Clear Else For Each oNode In oNotes oBrowserfolder.Add oNode Next End If Set oBrowserfolder = oSketchSyms.BrowserFolders("Watermarks") If Err Then Call oPane.AddBrowserFolder("Watermarks", oWatermarks) Err.Clear Else For Each oNode In oWatermarks oBrowserfolder.Add oNode Next End If Set oBrowserfolder = oSketchSyms.BrowserFolders("Template") If Err Then Call oPane.AddBrowserFolder("Template", oTemplate) Err.Clear Else For Each oNode In oTemplate oBrowserfolder.Add oNode Next End If Set oBrowserfolder = oSketchSyms.BrowserFolders("Tables") If Err Then Call oPane.AddBrowserFolder("Tables", oTables) Err.Clear Else For Each oNode In oTables oBrowserfolder.Add oNode Next End If Set oBrowserfolder = oSketchSyms.BrowserFolders("Coatings/Materials") If Err Then Call oPane.AddBrowserFolder("Coatings/Materials", oCoatings) Err.Clear Else For Each oNode In oCoatings oBrowserfolder.Add oNode Next End If oSketchSyms.DoSelect Dim oCommandMgr As CommandManager Set oCommandMgr = ThisApplication.CommandManager Dim oControlDef1 As ControlDefinition Set oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingResourceSort") oControlDef1.Execute End Sub

 

0 Likes