Cancel
Showing results for 
Search instead for 
Did you mean: 

Distance constraint problem

Valued Contributor
Valued Contributor

Hello all,

I am trying to give distance constraint to components using componentConstraint2.SetExpression(value.ToString());

for example

componentConstraint2.SetExpression(" 100 ");

componentConstraint2.SetExpression("  -100 ");

 

for both positive and negative values component is moving towards negative direction.

please refer the attached images.

 

3 REPLIES 3

Re: Distance constraint problem

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Hi,

 

have you tried setting a "fix" constraint to one of the objects prior to your code execution?

 

Regards,

MGeyer

Re: Distance constraint problem

Valued Contributor
Valued Contributor
Yes base component is fixed.

Re: Distance constraint problem

Valued Contributor
Valued Contributor

Set right hand side for the expression as your value


componentConstraint1.SetExpression("0");

Expression expression1;
expression1 = componentConstraint1.Expression;

componentNetwork1.AddConstraint(componentConstraint1);

expression1.RightHandSide = distance;

componentNetwork1.Solve();