Showing results for 
Search instead for 
Do you mean 
Reply

How to Add Property Names to Valid Value List?

I am trying to create a dynamic valid values list that shows all of the property display names from a different part family. When I run the code below, I receive an error that "Public member Value on type String not found."

 

Dim myPropertyCollection As Object
myPropertyCollection = Nothing

For Each oProp As Object In Me.Parent.Properties
	SetNextArrayElement(myPropertyCollection,oProp.objName)
Next

Result = MakeValidValues(myPropertyCollection,False)

I have tried two other tests with good results. Test #1 - I ran the following code to verify that oProp.objName refers to the property name text string. This test was successful. The parent part family has a property called "textboxDescription" and the result of this code is "textboxDescription." 

 

For Each oProp As Object In Me.Parent.Properties
	If right(oProp.objName,1) = "n" Then
		Result = oProp.objName
		Exit For
		Else
		Result = "Fail"
		End If
Next

Test #2 - I modified the instructions for producing a values list from a subpart collection. This will give me a valid values list of the parent property values rather than parent property names. 

 

Dim myPropertyCollection As Object

myPropertyCollection = Me.Parent.Properties

Result = MakeValidValues(myPropertyCollection,False)

Any suggestions for how I could resolve this and produce a valid values list of property names? Thanks in advance for your help!

1 REPLY

Re: How to Add Property Names to Valid Value List?

This should do the trick:

 

Dim VV As New Rulestream.Kernel.ValidValues

For Each RSProp As Rulestream.Kernel.PropertySF In ThePart(1).PropertyConstraints
	VV.Add(RSProp.PrettyName,RSProp.PrettyName)
Next RSProp

Result = VV

 

 

With the ThePart connection pointing to a part family with the following properties:

 

Architect.jpg

 

 

The VV formula above on a string property produces:

 

Engineer.jpg

 

Note the following caveats:

 

You can use the .properties function on the part family, but that brings back extra values which include valid-value formulas for example. Or, you can use the .propertyconstraints function which brings back everything with a local constraint (so it will be missing the PartNumber property).