Find point, axis and a rotation angle
-
(google translator)
Hello community of developers, I'm starting in the world of the SketchUp API and after much searching, I could not find anything to help me fix what I do.
What I want is to know how to get the point, the axis and angle of rotation made by the user, when performed with the tool rotation or when performed with the move tool (through the bounding box), using Ruby to find out the point, axis and angle made ββby the user is all I need,
I find no solution in any way -
It seems what your after is simply the component instance's transformation property.
-
thanks for responding, I would like to see an example of how to achieve this
-
@dan rathbun said:
Use other methods of the Geom::Transformation class.
Use the forum search feature to lookup previous topics on "Transformation", it has been discussed many times.
(google translator)
Thank you very much for responding Dan, sorry I think I should be more clear with my question, what I need is to detect if a group was rotated by the user and know where the point and axis from which it was rotated, not want to know the coordinates and orientation of the object but the coordinates (the point and axis) where the rotation was performed to detect when a group has been rotated, we currently do not know how (not if there is an observer for this). At the moment I have is: two equations derived from the Rodrigues formula for the rotation:
-
(where R is the rotation matrix, theta is the angle of rotation and omega is a vector parallel to the axis of rotation)
But it seems that do not serve me because I still missing the point of rotation, I have hope that there is a way using the API tools for what I do
-
# Get the selection; sel = Sketchup.active_model.selection # Get the first object from the selection obj = sel[0] # Get the object's transformation; ot = obj.transformation() # output the origin; puts("Object's Origin of Transformation; #{ot.origin.inspect}")
Use other methods of the Geom::Transformation class.
Use the forum search feature to lookup previous topics on "Transformation", it has been discussed many times.
-
@carlosneme said:
..., not want to know the coordinates ... of the object...
Sorry... I mis-labeled the code sample above. (I have fixed it.)
To get the origin:
obj.transformation.origin
and, to get the matrix:
obj.transformation.to_a
-
(Google Translate)
Thanks Dan, but it is proving difficult to express what I need, I do not know if the translator I'm using, I mean the coordinates where I run the rotation tool and I also mean that Ruby finds out when you have used this tool on a group -
Reading from the start...
You want to know what the user picks/enters in one of the native Tools, like Rotate or Move.
This is not possible.
But you can make your own tool that mimics Move or Rotate and then you will have access to the picked object and points, and calculated or entered values etc, because it's your code...Perhaps if we were to start again, before the beginning...
What is it you are trying to do?
Sometimes people are looking for an answer to the wrong question. -
(Google Translate)
thanks for answering TIG, I want to do is a copy type custom of groups or components.
I am struck by the suggestion of creating my own tools, I want to know if there is a simple plugin for a newbie like me to study and what it can take as an example, I searched and what i found were tools like Fredo6, when I see the code is too large and complex for my current knowledge
-
There are several Examples of Tool .rb files shipped with Sketchup - e.g. LineTool.
These will show how to construct and then call a Tool class, which then has access to lots of methods relating to user input - mouse, keys etc - without you having to reinvent them from scratch...
Also see the API docs... https://developers.google.com/sketchup/docs/ourdoc/tool
Advertisement