Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
emanuel.c
2490 Views, 8 Replies

Modify iProperty of every part in an assembly

I have this short piece of code. It fills in the Description iProperty with the part's browser name in model tree. It works great for all parts and subassemblies found at the top level of an assembly, but it stops there. How can I have it work on ALL parts including parts in sub and sub-sub assemblies etc.?

Many thanks!

'Copy file name (browser name) to description for each occurence in an assembly and subassembly

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences in the assembly
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
    Dim oName As String
    oName = oOccurrence.Name
	'split browser name between name and sequence number (what follows after ":") 
	ONameArray = Split(oName, ":")
	oName=ONameArray(o)	
    'Fill in part Description from File Name
	iProperties.Value(oOccurrence.Name, "Project", "Description") = oName
Next