Search all parts with a assembly and sub-assembly for a custom iproperty and fill it in

Search all parts with a assembly and sub-assembly for a custom iproperty and fill it in

Anonymous
Not applicable
390 Views
1 Reply
Message 1 of 2

Search all parts with a assembly and sub-assembly for a custom iproperty and fill it in

Anonymous
Not applicable

Hello

 

I am just looking for a simple rule to search through all parts of a assembly and any sub assemblies, find a custom iproperty that will only exist in a few of the parts, fill it in with a value. It doesn't need to create it if it doesn't exist, just find the occurrences of it and fill it in. But i want it to always override what is already in there.

 

thank you ahead of time!

0 Likes
Accepted solutions (1)
391 Views
1 Reply
Reply (1)
Message 2 of 2

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

Try this iLogic rule 🙂

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oDef As AssemblyComponentDefinition = oAsm.ComponentDefinition
Dim pName As String = "TestProperty" 'Property name here
Dim pValue As Object = "TestValue" 'Property value here
For Each oRefDoc As Document In oAsm.AllReferencedDocuments
	If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject _
		AndAlso oDef.Occurrences.AllReferencedOccurrences(oRefDoc).Count > 0
		On Error Resume Next
		oRefDoc.PropertySets("Inventor User Defined Properties")(pName).Value = pValue
	End If
Next

 

0 Likes