Message 1 of 8
Create as new part from an occurance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My final goal is to replace all leaf occurrences with a copy that gets the filename as the Part Number of this occurance.
I'm not sure if I have to make new parts first and then replace them , or that I can do an equivalent in iLogic to the " save and replace component" command.
Anyhow this is the code I have so far.
I 'm producing the correct filenames already but it fails to do a "save as" or a "replace"
SyntaxEditor Code Snippet
fmgr = ThisApplication.Filemanager For Each file In fmgr.files doc = ThisApplication.Documents.ItemByName (file.fullfileName) compdef = doc.ComponentDefinition Dim newname As String 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 Try 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") 'occ.Replace( newname , True) occ.SaveAs (newname , True) Catch MessageBox.Show("error") End Try End If Next occ End If Next file