C# get rotation of Geometry

how can i get current rotation of an geometry
i get geometry by using doc.Objects.FindGeometry(guid)
and now i want to get rotate of this object

Hi - objects don’t store information about previous translations. Only block instances carry a transformation matrix.

1 Like

is there any way to save previus of translation ?

Hi @iranikhaze,

Why do you need to do this? What problem would this help you solve?

– Dale

1 Like

thanks @dale
i made a plugin for rhino ( not grasshopper just for rhino in c# )
i use 2D physics engines - (Box2d and farseer) libraries
my physic structure is lookalike blow
made Shapes in Rhino and get the GUI of object added to rhinoDoc
also made similar shape in my physic engine and named it lookalike rhinoshape GUID
i start a LoopTask in my c# code and update my physics frame(step) also get my physics shape new position and rotation
so at this time i must set all off physics data to my rhino shapes
i use the GUID to find object and set the transform.translate to substracted transform.translate to previus frame for positions its work like charm and ok i show it to you at blow

Point3d center = (doc.Objects.Find(guid).Geometry as Curve).GetBoundingBox(true).Center;
doc.Objects.Transform(guid, Rhino.Geometry.Transform.Translation( body.Position.X - center.X, body.Position.Y - center.Y, 0),true );

so i want do it for rotations

Hi @iranikhaze - whichever physics engine you are using, you should be able to retrieve the body orientations directly from there, rather that trying to somehow extract it afterwards from the output in Rhino.

1 Like

i’m glad to meet you @DanielPiker
my physics engine get me a Rotation result
but i don’t know how to set it to rhino geometries
for example
at this step angle is 90degrees i change it to radiance and set it to my shape at first frame it works good
at the next step the physics engine get me 0 degrees i change it to radiance and set it to my shape in rhino but the shape didn’t rotate :neutral_face: but it should rotate my rhino shape -90 degrees

Like in our other conversation about the positions, it sounds like the issue is about keeping an unaltered initial geometry.
One approach would be to get the relative translation/rotation from one frame to the next, and reorient your shape from the previous frame by this small amount with each iteration. This could potentially build up errors though.
Better I think would be to keep a fixed rest-state version of your geometry which always stays in the same position/orientation, then at each iteration, make a copy of this, and orient it to the correct frame at that iteration. Most physics engines will give you the body position/orientation in this form, rather than relative to previous frame.