Import Sketches Symbols from template, retaining folder structure

Import Sketches Symbols from template, retaining folder structure

Patrick1323
Enthusiast Enthusiast
548 Views
1 Reply
Message 1 of 2

Import Sketches Symbols from template, retaining folder structure

Patrick1323
Enthusiast
Enthusiast
Hello, here is a script i wrote, it imports the Sketches Symbols from template idw. But it doesn't copy the folders. How do I retain the folder structure? Sub Skizzensymbole_aktualisieren() Dim oDrawing As DrawingDocument Set oDrawing = ThisApplication.ActiveDocument Dim oTemplate As DrawingDocument Set oTemplate = ThisApplication.Documents.Open("C:\template.idw", False) Dim oSourceSketchedSymbolsDef As SketchedSymbolDefinitions Set oSourceSketchedSymbolsDef = oTemplate.SketchedSymbolDefinitions For Each symbolDef In oSourceSketchedSymbolsDef Call symbolDef.CopyTo(oDrawing, True) Next oTemplate.Close End Sub
0 Likes
Accepted solutions (1)
549 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor
Accepted solution

Pretty sure you have to re-add the folders.

 

Something like below should get you started.

 

Sub AddFolders()

Dim oPane As BrowserPane
Dim oNode As BrowserNode
Dim oDwgName As BrowserNode
Dim oDwgRes As BrowserNode
Dim oSktch As BrowserNode
Dim oFolder As BrowserFolder
Dim oOccurrenceNodes1 As ObjectCollection
Dim oOccurrenceNodes2 As ObjectCollection
Dim oOccurrenceNodes3 As ObjectCollection
oOccurrenceNodes1 = ThisApplication.TransientObjects.CreateObjectCollection
oOccurrenceNodes2 = ThisApplication.TransientObjects.CreateObjectCollection
oOccurrenceNodes3 = ThisApplication.TransientObjects.CreateObjectCollection

oPane = ThisApplication.ActiveDocument.BrowserPanes("Model")

oDwgName = oPane.TopNode 'Is the WO# and sheet name
oDwgRes = oDwgName.BrowserNodes.Item("Drawing Resources")
oSktch = oDwgRes.BrowserNodes.Item(4)

For Each oFolder In oSktch.BrowserFolders
	oFolder.Delete
Next

For Each oNode In oSktch.BrowserNodes
	oStr1 = Right(oNode.FullPath, Len(oNode.FullPath) - InStrRev(oNode.FullPath, ":", -1))
	If oStr1 = "Assembly/Weldment Label" Or _
	    oStr1 = "Part Label" Or _
		oStr1 = "Section/Detail Label" Or _
		oStr1 = "Flat Plate Layout Label" 
	oOccurrenceNodes1.Add(oNode)
	End If
	
	If oStr1 = "Detail Callout" Or _
		oStr1 = "Section Symbol" Or _
		oStr1 = "Orientation"
	oOccurrenceNodes2.Add(oNode)
	End If
	
	If oStr1 = "Assembly Weight" Or oStr1 = "Reference Drawing"
	oOccurrenceNodes3.Add(oNode)
	End If
Next

oPane.AddBrowserFolder("Title Block Symbols", oOccurrenceNodes3)
oPane.AddBrowserFolder("Symbols", oOccurrenceNodes2)
oPane.AddBrowserFolder("Labels", oOccurrenceNodes1)

oSktch.DoSelect

Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager

Dim oControlDef1 As ControlDefinition
 oControlDef1 = oCommandMgr.ControlDefinitions.Item("DrawingResourceSort")
oControlDef1.Execute

End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes