Assign user parameter to dimension constraint

Assign user parameter to dimension constraint

Anonymous
Not applicable
805 Views
2 Replies
Message 1 of 3

Assign user parameter to dimension constraint

Anonymous
Not applicable

I have a code that creates a Point and Plane Distance constraint. It also creates a user parameter. I'm looking for a way to assign that parameter to the dimension I just created. 

 

 

SyntaxEditor Code Snippet

oParameter = oMyParameter.AddByValue("X1H_1", 10, UnitsTypeEnum.kMillimeterLengthUnits)
    pointArray = points.Add(tg.CreatePoint(Parameter("X1H_1"), 20, 30))
    DimCon = sketch1.DimensionConstraints3D.AddPointAndPlaneDistance(pointArray, oCompdef.WorkPlanes.Item(1))

 

The above code will create the parameter, create the point based off that parameter, and create the constraint, but in the model when you click on the dimension it is controlled by a model parameter, not the user parameter. If I update the user parameter in another code the model will not be updated because of this. 

 

Is there a way to assign a user parameter to a dimension like you can through the UI by typing the user parameter name into the edit dimension text box?

 

I'm currently attempting to set the model parameter's equation to the user parameter since that's what happens when you do it manually but I'm not having any luck.

modelparameter.Equation = userparameter doesn't work and

modelparameter.Value = userparameter only changes the value.

modelparameter.Expression = userparameter does the same thing as .Value

 

Thanks for any help.

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

Anonymous
Not applicable
Accepted solution

Figured it out 30 Seconds after posting.

 

modelparameter.Expression = "userparameter"

 

the key is to enter whatever the user parameter name is as a string.

Message 3 of 3

sam
Advocate
Advocate

Thanks.😊

0 Likes