Rotate property can't be set

I set by “SetWPR”.It will be set when call but it will be reset to zero automatically after.

 

                        _application.World.Components.Last().TransformationInWorld.SetWPR(
                            new Vector3(Convert.ToDouble(Rxyz[0]), Convert.ToDouble(Rxyz[1]), Convert.ToDouble(Rxyz[2])));

 

It will be reset immediately.

as

Hy,

your parameters of SetWPR is a vcVector. The help says the parameters are reals.

Maybe:

_application.World.Components.Last().TransformationInWorld.SetWPR(float(Rxyz[0]), float(Rxyz[1]), float(Rxyz[2]));

Regards

Feature

 

                        _application.World.Components.Last().TransformationInWorld.SetWPR(
                            Convert.ToSingle(Rxyz[0]), Convert.ToSingle(Rxyz[1]), Convert.ToSingle(Rxyz[2]));

SetWPR without three parameters, just one.

Matrix is a struct type, which means TransformationInWorld getter returns a copy of the transformation matrix. Therefore, you have to assign it back after modifying:

ISimComponent comp = _app.World.Components.First();
Matrix currentPosition = comp.TransformationInWorld;
currentPosition.SetWPR(new Vector3(10, 20, 40));
comp.TransformationInWorld = currentPosition;
1 Like

thx, it works!

However, I think using Extension Methods is better!