
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a main assembly. Using ilogic I have created a configuration of parts and sub-assemblys. Once I have a configuration I like, I want to click a button and save a "copy as" to a new folder, and a different name. Would like all the used parts & sub-assemblys to be placed in this new folder too.
Also I want to delete suppressed parts and sub-assemblys in the main assembly as its saved, I also want parts in sub-assemblys deleted too, they will be suppressed. My sub-assemblys have components suppressed that I want deleted too. After all this is done I would like to have the original assembly opened again, or maybe it didn't close at all.
Below I have code that will save the master assembly to a specified folder and some parts, and it deletes all main assembly suppressed parts and suppressed sub-assemblys but not the parts and sub-assemblys that are suppressed at the sub-asembly level, if you know what I mean. The below code also does'nt copy over all the sub-assemblys. I want it to work lile packNgo.
I found this code online and tried to piece it together. I am still trying to learn this stuff..
Here is my code:
'Deleting the suppressed parts from the assembly
Dim oComp As ComponentOccurrence
Dim oComps As ComponentOccurrences
oComps = ThisDoc.Document.ComponentDefinition.Occurrences
For Each oComp In oComps
If Component.IsActive(oComp.Name) = False Then oComp.Delete
On Error Resume Next
Next
'Delete Empty Folders
oDoc = ThisDoc.Document
oPane = oDoc.BrowserPanes("Model")
oTopNode = oPane.TopNode
'Iterate through the browser folders
For Each oFolder In oTopNode.BrowserFolders
i = 0
'Iterate through the nodes in the folder
oFolderNodes = oFolder.BrowserNode.BrowserNodes
For Each oNode As BrowserNode In oFolderNodes
'count the nodes
i = i+1
Next
'delete the folder if the count = 0
If i = 0 Then
oFolder.Delete
Else
End If
Next
'Saving a copy of the assembly components
Dim refDocs as DocumentsEnumerator=ThisDoc.Document.AllReferencedDocuments
Dim compCount As Integer = refDocs.Count
For j = 1 To compCount
refDocs.item(j).SaveAs( "C:\Users\aws01\Documents\Library\Pole Configurations\Parts\Part" & j & ".ipt", False)
Next
'Saving a copy of the assembly document
ThisDoc.Document.SaveAs( "C:\Users\aws01\Documents\Library\Pole Configurations\Assembly\PoleConfig.iam", False)
'---------------------------------------------------------------------------------------------------------------------------
'Save DWF File
Test=InputBox("Add File name", "Please Add your file name", "Prefix number - File")
If (Not System.IO.Directory.Exists(Test)) Then
System.IO.Directory.CreateDirectory(Test)
End If
ThisDoc.Document.SaveAs("C:\Users\aws01\Documents\Library\Pole Configurations\" &Test &".dwf", True)
Thanks Very much
Anthony
Solved! Go to Solution.