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: 

Get custom iProperties of parts in an assembly

1 REPLY 1
SOLVED
Reply
Message 1 of 2
lantzwoodworking
100 Views, 1 Reply

Get custom iProperties of parts in an assembly

I'm trying to write a rule to retrieve a Custom iProperty value (text) from two parts in an assembly ("side.ipt" and "back.ipt") and store that information into that assembly's User Parameters (Material_Side and Material_Back).  This is the code that I have so far.

 

oOccurrences = ThisDoc.Document.ComponentDefinition.Occurrences																'Get the set of occurrences in this assembly document
For Each oComp As ComponentOccurrence In oOccurrences																		'Cycle through each component in the set
	oCompName = oComp.Name																									'Get the browser name of the component

	Try
		oCompMaterial = oComp.OccurrencePropertySets.Item("Inventor User Defined Properties").Item("Mat_Name").Value		'Get iProperty value from custom field named "Mat_Name"
	Catch
		oCompMaterial = "Error"
	End Try

	If InStr(oCompName, "side") > 0 Then																					'Check if the desired bit of text is in the component's name
		Material_Side = FormatAsFraction(NomThick_Side) & " " & oCompMaterial												'side material

	Else If InStr(oCompName, "back") > 0 Then																				'Check if the desired bit of text is in the component's name
	Material_Back = FormatAsFraction(NomThick_Back) & " " & oCompMaterial													'back material 
	End If

Next

 

As best I can tell the issue is on line 7 as the oCompMaterial value that is returned to me is the catch value "Error" and not the iProperty value of the part.  Any suggestions would be appreciated.

 

Thanks.

Labels (2)
1 REPLY 1
Message 2 of 2

I figured it out.  Code posted below in case it helps anyone else later.  Thanks.

 

oOccurrences = ThisDoc.Document.ComponentDefinition.Occurrences																'Get the set of occurrences in this assembly document
For Each oComp As ComponentOccurrence In oOccurrences																		'Cycle through each component in the set
	oCompName = oComp.Name																									'Get the browser name of the component
	oCompMaterial = iProperties.Value(oCompName, "Custom", "Mat_Name")

	If InStr(oCompName, "side") > 0 Then																					'Check if the desired bit of text is in the component's name
		Material_Side = FormatAsFraction(NomThick_Side) & " " & oCompMaterial												'side material

	Else If InStr(oCompName, "back") > 0 Then																				'Check if the desired bit of text is in the component's name
		Material_Back = FormatAsFraction(NomThick_Back) & " " & oCompMaterial												'back material 
	End If

Next

 

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

Post to forums  

Autodesk Design & Make Report