Sorry for the delay. Busy at work. I created some quick code for you to try out.
See below code.
'Assuming the main assembly is open and active when you run this rule
'To change the main assembly's Part number use this line
iProperties.Value("Project", "Part Number") = "Whatever you want to put here"
'To change the Part Number of a ComponentOccurrence within the main assembly
'to its "Name" you would use code similar to the following
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
'For a single Occurrence...Uncomment the next line (you may need to change which Occurrence)
'Dim oOcc As ComponentOccurrence = oADoc.ComponentDefinition.Occurrences.Item(1)
'Or...to loop through all Occurrences - Uncomment the next 3 lines
'For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
' iProperties.Value(oOcc.Name, "Project", "Part Number") = oOcc.Name
'Next
'Or...another route
For Each oDoc As Document In oADoc.AllReferencedDocuments
'Open each referenced document, so you can access its iProperties
ThisApplication.Documents.Open(oDoc.FullFileName, False)
oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oDoc.DisplayName
Next
I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.
Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.
- Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
- MessageBox, InputBox, and InputListBox Size & Format Options Click Here
- Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
- Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
- Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
- Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
- SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum
Wesley Crihfield

(Not an Autodesk Employee)