sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Find point, axis and a rotation angle

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 739 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      Carlosneme
      last edited by

      (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

      1 Reply Last reply Reply Quote 0
      • daikuD Offline
        daiku
        last edited by

        It seems what your after is simply the component instance's transformation property.

        Clark Bremer
        http://www.northernlightstimberframing.com

        1 Reply Last reply Reply Quote 0
        • C Offline
          Carlosneme
          last edited by

          thanks for responding, I would like to see an example of how to achieve this

          1 Reply Last reply Reply Quote 0
          • C Offline
            Carlosneme
            last edited by

            @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:


            formulas

            1 Reply Last reply Reply Quote 0
            • C Offline
              Carlosneme
              last edited by

              (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


              pivot point

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                # 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.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @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

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    Carlosneme
                    last edited by

                    (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

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      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. 😕

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Carlosneme
                        last edited by

                        (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


                        capture3.jpg

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          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

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement