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, also I 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 didnt 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 doesnt copy over all the sub-assemblys. I want it to work lile packNgo.
Here is my code:
SyntaxEditor Code Snippet
'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).SaveCopyAs( "C:\MyPath\Parts\Part" & j & ".ipt", False) 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:\MyPath\Assembly\PoleConfig.iam", False) 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) 'ThisDoc.Document.SaveAs(Test & "\" &Test &".iam", True)
Thanks
Has anyone been able to understand what I needed to do here? If I was unclear let me know and I will try and explain.
Thanks
May want to post this question over in the Inventor customization forum" http://forums.autodesk.com/t5/inventor-customization/bd-p/120
Mark Lancaster
& Autodesk Services MarketPlace Provider
Autodesk Inventor Certified Professional & not an Autodesk Employee
Likes is much appreciated if the information I have shared is helpful to you and/or others
Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.
Can't find what you're looking for? Ask the community or share your knowledge.