Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ILogic - Summing parameter based on an Iproperty

0 REPLIES 0
Reply
Message 1 of 1
rtrayes13
361 Views, 0 Replies

ILogic - Summing parameter based on an Iproperty

In an assembly, I am attempting to sum a user defined iProperty called "LENGTH" based on a user defined iProperty called "PART NAME".  Each component in the assembly has an iProperty "PART NAME" value.   There may possibly be two or more different "PART NAME" values that I will need to sum independently.  I currently have the following code that I adapted to sum all of the lenths in the assembly, I am just unsure how to segregate the values by PART NAME. 

 

'- - - - - - - - - - - find or create custom iProperty - - - - - - - - - - 
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document
'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments      
 
Dim propertyName1 As String = "LENGTH"
 'define custom property collection
oCustomPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties")
Try
'look for property
oProp = oCustomPropertySet.Item(propertyName1)
Catch
' Assume error means not found so create it
oCustomPropertySet.Add(0, propertyName1)
End Try
Next

'- - - - - - - - - - - sum the custom iProperty - - - - - - - - - - 
'clear the custom property in the assembly 
iProperties.Value("Custom", "LENGTH") = 0

'set a reference to the assembly component definintion.
'This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components
'(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
'custom property in the assembly 
xNumber = iProperties.Value("Custom", "LENGTH") 
'custom property in the parts
yNumber = iProperties.Value(oOccurrence.Name, "Custom", "LENGTH")
sumNumber = xNumber + yNumber
'set custom property values
iProperties.Value("Custom", "LENGTH") = sumNumber 
Else
End If
Next

 

 

Any advice is greatly appreciated.

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report