Set center of rotation for transform in 3D model

Hello.

I want to change the center of rotation of a 3d model(stl). I would like to rotate it in his own center of rotation (In the middle of the object). Because now I only can rotate it with a rotation around the 0.0 ax.
Thanks for your answers and help

1 Like

There is a recipe for this in the script repository https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#rotate-a-node-around-a-specified-point

1 Like

:grinning:
learned a ton, very useful to me.

Sorry I don’t understand the process.Shall I paste the script somewhere (in the code section?) I can’t rotate around a center of rotation I’d like to choose. thanks

Yes, you can paste the code in the Python console (which can be opened/hidden by pressing Ctrl-3). This area is a command prompt for an interactive python session in Slicer’s python environment. Many scripts in the script repository will work without modification when pasted directly to the python console, however this one will need a little bit of editing by you before pasting, and a little bit of pre-work before you run it.

First you need to create a markups point where you want the center of rotation to be. If this is the first markups point you have created and you have not specified a name, the default name will be “F”. If the name of the markups node is not “F”, you need to change the second line of the script so that the name in getNode() matches the name of your markups node.

Next you need to create two transform nodes, one which will serve as your rotation
controller, and one which will be automatically updated to represent rotation around your chosen center rather than around the origin. You can create linear transform nodes in the Transforms module. You need to make a note of the names of the transforms you create and change lines 4 and 6 of the script to contain those names in the getNode() calls.

Then you are ready to paste the modified script (the whole thing at once) into the python console, which will run it. Any modifications to the rotation controller transform will automatically result in modifications to the other transform such that it represents the same rotation, but around your chosen center instead of around the origin.

Next, you need to add the automatically updating transform as the parent transform to whatever you want to be rotating. There are many ways to do this in Slicer. You can use the Transforms module or the Transform hierarchy tab of the Data module, but the simplest is to use the Subject hierarchy tab of the Data module. Find the object you want to rotate on the list, and then look to the right, there will be a small icon which looks like two rotated grids. Right click on that and then select the name of the automatically updating transform.

Finally, you can go to the Transforms module, select the rotation controller transform, and move the sliders in the “Rotation” section. All objects with the automatically updating transform as the parent transform will now be rotated around your chosen center point. That center point can also be interactively moved as desired.

thanks so much but a video would be great . I know we are all busy.
Best regards

FYI, @Sunderlandkyl is working on a new transform widget that will allow rotation around a chosen point (and translation along object or world axes) in both 2D and 3D views. The first version of the feature may be available in the Slicer Preview Release within a couple of weeks.

You can track the progress of this work here:

4 Likes