Message 1 of 5
Save As all occurrences from an assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The code below should make a copy of every part in an assembly and save it with a specific File name.
I think I have it all right up to the moment the part needs to be saved , I get an unknow error.
Any ideas what is going on here?
SyntaxEditor Code Snippet
'check this file is an assembly Dim doc As Document = ThisApplication.ActiveDocument If doc.DocumentType = kPartDocumentObject Then MessageBox.Show("This rule can only be run in an assembly file!", "Cadline iLogic") Return End If Dim newname As String Dim compdef As ComponentDefinition compdef = doc.ComponentDefinition If (doc.documenttype = 12291) Then ' only do this for assembly or subassembly For Each occ In compdef.Occurrences If (occ.definition.type =83886592) Then ' only do this for part Dim oNewDoc As PartDocument oNewDoc = ThisApplication.Documents.Add(kPartDocumentObject, , False) occ.Name = iProperties.Value(occ.Name,"Project", "Part Number") newname = iProperties.Value(occ.Name,"Project", "Part Number") & ".ipt" MessageBox.Show("I found variable: " & newname , "Info") ThisApplication.SilentOperation = True 'oNewDoc = occ.Definiton.Document.SaveAs(newname, True) oNewDoc.SaveAs(newname, False) ThisApplication.SilentOperation = False End If Next End If