MotionController V2 - Accessing Properties

Hi together,

I’m modelling a component using the new MotionController and I’m using the “FromExpression” thing as the ValueSource. However, in the ValueExpression field I cannot access any Properties of the component.

Is there any way to access the components properties or to add some “local” properties?

Hello,
There is currently no way to access component properties in joint value expressions, and it is so intentionally. I can not comment on the implementation details, but the benefits of doing so are better performance and robustness, when only the driver value in the expression is a dynamically changing variable.

Please see the below example that I picked from a parametric scissor lift modelled using the motion controller. Basically the parameter’s value is just injected in the joint value expression in the parameter’s OnChanged event.

def length_changed(prop):
  # Remove after ValueExpression supports component property references
  l = prop.Value
  link1.Joints[0].ValueExpression.Value = "-asind((J1/2) / {})".format(l-200)
  # And same for other joints here

link1 = comp.findNode("Link1")
length_prop = comp.Properties["TableLength"]
length_prop.OnChanged += length_changed

Then if there are other variables that would be needed to change dynamically, it would make sense to model those as drivers.