Cancel
Showing results for 
Search instead for 
Did you mean: 

Rotation of a Graphic

Valued Contributor
Valued Contributor

Hello All,

 

I am trying to rotate Graphics to an angle. I have tried the SetGraphicRotation. But my issue is to turn the Graphic twice( Turn it to an angle, for example, 45° along the X-Axis in the first call and turn it x° in the Z-Axis in the next call). When the second rotation is called, I want the new rotation to be added to the previous rotaion. Unfortunately, the previous rotation is not taken. I am using the command SetGraphicRotation. It is just setting another Rotation to the Graphic and not adding another Rotation.

 

When doing it manually,all I have to do is to set the first rotation, and click on Add Rotation> Define Angle> Define Axes, it works perfectly as desired but not through Simtalk.  Since it is not an object but a Graphic, I cannot use the "_3d.Rotation" command too. Is there a way to do this over Simtalk?

 

Thank you so much.

 

Regards,

Simpulse

 

EDIT: I am looking for a command to Add Rotation and not SetRotation.

6 REPLIES

Re: Rotation of a Graphic

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello Simpulse,

You can use the method '_3D.addGraphicTransformation'.

This is the more general method which allows you to add a translation as well. In your case you just use a zero translation.

 

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Rotation of a Graphic

Valued Contributor
Valued Contributor

Hello Ralf,

 

Thank you for your reply. However, the previous rotation is not taken in the succeeding rotation. I have attached a test model if it helps. During the second call of the method, I want the previous rotation of 60° to also be taken into account when calcualting the new Rotation. I can do this manually by setting the first rotation, opening the 3D properties> Add Rotation as shown in the picture attached. I would like to know if a new rotation can be added by code. Could you please take a look into it? Thank you so much for your time.

 

Regards,

Simpulse

Re: Rotation of a Graphic

Valued Contributor
Valued Contributor
Oh Sorry. My bad. I did not try the AddGraphicTransformation. Smiley Happy I tried the "Set" again. I will check it and get back to you. Thank you so much. Sorry again. Smiley Very Happy

Re: Rotation of a Graphic

Valued Contributor
Valued Contributor
Perfect. Exactly what I needed. Thank you so much, Ralf. Smiley Happy

Regards,
Simpulse

Re: Rotation of a Graphic

Siemens Phenom Siemens Phenom
Siemens Phenom

I'd like to add one final suggestion:

With _3D.set/addGraphicRotation, you cut the graphic inheritance (if it isn't already cut). If you actually wanted to modify your graphics for a particular object, that's alright.

But if you actually just wanted to accumulate rotations of an entire object (for instance a whole SingleProc), typically, you would have just assigned a new value to the _3D.Rotation attribute. To add a rotation in such a case, you can use the helper function basis.~._3D.concatenateRotations.

This function allows you to calculate a value that you can assign to e.g. _3D.Rotation:

-- Example 1: Two "anonymous" rotations
var r := basis.~._3D.concatenateRotations(makeArray(45, 0, 0, -1), makeArray(45, 0, 0, -1))
-- The result will be [90, 0, 0, -1] or [-90, 0, 0, 1].
-- This also works with different rotation axes but with the same axis I can write the example without a calculator.
myObject._3D.Rotation := r

-- Example 2: "Add Rotation"
var r := basis.~._3D.concatenateRotations(myObject._3D.Rotation, makeArray(10, 1, 0, 0))
-- The result will be the same as "Add Rotation" with 10 degrees around the X axis
myObject._3D.Rotation := r

You can also use the calculation result for _3D.setGraphicRotation, of course.

 

 I know you wrote that you are working on a graphic instead of on an object but I frequently saw that as a workaround for actually transformating the object visually...

Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution

Re: Rotation of a Graphic

Valued Contributor
Valued Contributor
Thank you so much, Peter. I actually tried to use concatenateRotations before. I could not get it to work with Graphics. However, I understood the method call a lot better now.

Regards,
Simpulse