Creating and Updating custom iProperties from an assembly

Creating and Updating custom iProperties from an assembly

a81383
Enthusiast Enthusiast
432 Views
3 Replies
Message 1 of 4

Creating and Updating custom iProperties from an assembly

a81383
Enthusiast
Enthusiast

Hello,

 

I'm running into some issues trying the set the value on a custom iProperty within components of an assembly. I have a separate set of code that opens each component within the assembly. The code below is then ran within each component. It works within the model you run it within. But for the sub-components it adds the custom iProperty but does not give it a value. Even if I type the value directly into line 13 it still does not get applied to the lower level components.

 

Dim oDoc As Document = ThisApplication.ActiveDocument

InputVar = SharedVariable("Inputs")

Dim propertyName As String = "PL_Code"

oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Try
oProp = oCustomPropertySet.Item(propertyName)
Catch
' Assume error means not found so create it
oCustomPropertySet.Add("", propertyName)
End Try

Dim oPropSet As [Property] = oCustomPropertySet.Item(propertyName)
	
If oPropSet.Value() = "" Then Call PropPL_Code(oPropSet, InputVar)

 

Private Sub PropPL_Code(oPropSet, InputVar)
	If InputVar = False Or Poduct_Code = "" Then
		iLogicVb.RunExternalRule("ProductLine Pick List Copy")
		Poduct_Code = SharedVariable("Product_Code")
		If String.IsNullOrEmpty(Poduct_Code) Then
			MsgBox("PL_CODE not found. Exiting.", vbCritical, "")
			Exit Sub
		End If
	End If
	oPropSet.Value() = Poduct_Code
End Sub

 

0 Likes
Accepted solutions (1)
433 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

What version of Inventor are you using (2019, 2022, 2023, etc.)?  If using 2022 or newer, then are there any ModelState customizations anywhere within the main assembly, or in any of its components, or sub-components?  If ModelStates are involved, then you may be attempting to work with ModelState 'member' versions of those documents, which will be ReadOnly.

Edit:  Also, are you aware of the two different spellings:  "Product_Code" & "Poduct_Code"?

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

a81383
Enthusiast
Enthusiast

@WCrihfield, Haha I feel dumb. So the code is working. But it's only updating the Master model state. Is there a way to set the iProperty value for all the model states?

0 Likes
Message 4 of 4

a81383
Enthusiast
Enthusiast

@WCrihfield, I've got it working now. It was a model states "issue". Also, no I did not notice that typo. Great catch!

Thank you!

0 Likes