How to control the axes of mechanical units with SDK?

Hello everyone, I am trying to control a mechanical unit, like a robot, via an add-in. I tried the following code, but without success. The code works fine, but I cannot use the SetJointValues function to move the axes of my mechanical units. Does anyone have an example or any ideas, please?

Station station = Station.ActiveStation;

List objets = new List(station.GetGraphicComponents());

foreach (ProjectObject objet in objets)
{

if (objet is Mechanism mecha1)
{
Logger.AddMessage(“Flag 0”);
double jointValues = new double { 30.00, 30.00, 30.00, 30.00 };
Logger.AddMessage(mecha1.Name);
Logger.AddMessage(mecha1.NumActiveJoints.ToString());
Logger.AddMessage(“Flag 1”);
mecha1.SetJointValues(jointValues, false);
Logger.AddMessage(“Flag 2”);

}

}

Hello,

You can have a look how I’ve done Here.

Request for the mastership before setting the values?