sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    InputPoint and snapping

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 4 Posters 524 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.
    • J Offline
      jorat1346
      last edited by

      Hi,

      i'm searching a way to change snapping behavior inside an InputPoint. More specifically, there is more than 15 possibilities for snapping:
      Endpoint, Midpoint, Intersection, On Face, On Edge, On Red Axis, On Blue Axis, On Green Axis, From Point, Perpendicular, Parallel, Tangent at Vertex, Half Circle, Square and more. And can get the complete list at http://sketchup.google.com/support/bin/answer.py?hl=en&answer=70143. How can I enable/disable one of those?

      Jo

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Unfortunately, you can't.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          I've been toying with the idea of mimicing AutoCAD by using PickHelper (instead of InputPoint.)

          There are times when you really want to control the Osnap point, in the old way.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            Yea, you have to make you own Inputpoint to control what you snap to. For BezierSurface I'm doing that so I can snap to the Bezier control point. The Bezier control points gets priority first, then if none are picked it uses an InputPoint.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • J Offline
              jorat1346
              last edited by

              @thomthom said:

              Yea, you have to make you own Inputpoint to control what you snap to. For BezierSurface I'm doing that so I can snap to the Bezier control point. The Bezier control points gets priority first, then if none are picked it uses an InputPoint.

              Is there any chance that we can share it with us? I'm trying to do it but it's quite a bitch. Namely translate the mouse 2d coordinate (x,y) into 3d coordinate.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @jorat1346 said:

                I'm trying to do it but it's quite a bitch. Namely translate the mouse 2d coordinate (x,y) into 3d coordinate.

                I just use the PickHelper class to get the various entities under the mouse. http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.html

                Thomas Thomassen β€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

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

                  @jorat1346 said:

                  @thomthom said:

                  Yea, you have to make you own Inputpoint to control what you snap to. For BezierSurface I'm doing that so I can snap to the Bezier control point. The Bezier control points gets priority first, then if none are picked it uses an InputPoint.

                  Is there any chance that we can share it with us? I'm trying to do it but it's quite a bitch. Namely translate the mouse 2d coordinate (x,y) into 3d coordinate.

                  The whole inputpoint and pickhelper things etc are designed to help you to do this BUT you must do it with a 'Tool' that you define as a new class with the required appropriate 'special' def methods like initialize(). activate(), onMouseMove(), draw() etc etc... See the linetool.rb et al example that comes with SUp... You then activate the tool from a menu item [or toolbar or whatever] and it does your bidding... πŸ˜•

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jorat1346
                    last edited by

                    @thomthom said:

                    @jorat1346 said:

                    I'm trying to do it but it's quite a bitch. Namely translate the mouse 2d coordinate (x,y) into 3d coordinate.

                    I just use the PickHelper class to get the various entities under the mouse. http://code.google.com/apis/sketchup/docs/ourdoc/pickhelper.html

                    That doesn't work well enough for me. :S

                    @tig said:

                    The whole inputpoint and pickhelper things etc are designed to help you to do this BUT you must do it with a 'Tool' that you define as a new class with the required appropriate 'special' def methods like initialize(). activate(), onMouseMove(), draw() etc etc... See the linetool.rb et al example that comes with SUp... You then activate the tool from a menu item [or toolbar or whatever] and it does your bidding... πŸ˜•

                    Humm yeah, it's already what I'm doing.

                    You see, what I'm really trying to do is to make a tool similar to the rotation tool (protractor). The problem is that when I move the mouse around to pick an angle, it keep on snapping on about anything principally because of the "From Point" snapping. So to disable that, it seen for now that I have to make my own version of InputPoint so I can adjust the behavior to what I want.

                    Right now, I'm at trying to get the transformation matrix of the view which doesn't seem to be easy to get. So I have two choices here: either I try to remake all the math behind or try to find that matrix using a series of coordinate obtained with view.screen_coords. This matrix will allowed me to project a 2d mouse coordinate on a 3d plane which will be perfect to find an angle.

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

                      PickHelper does not use snapping. InputPoint does.

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        @dan rathbun said:

                        PickHelper does not use snapping. InputPoint does.

                        Yes, but if you want to make your own custom InputPoint class that let you snap to what you want you'll need PickHelper to get the entities under the cursor.

                        Thomas Thomassen β€” SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          jorat1346
                          last edited by

                          @dan rathbun said:

                          PickHelper does not use snapping. InputPoint does.

                          I totally understand that, but PickHelper doesn't have the .position function that InputPoint have and that I desperately need.

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            @jorat1346 said:

                            I totally understand that, but PickHelper doesn't have the .position function that InputPoint have and that I desperately need.

                            ray = view.pickray result = model.raytest( ray )

                            http://code.google.com/apis/sketchup/docs/ourdoc/view.html#pickray
                            http://code.google.com/apis/sketchup/docs/ourdoc/model.html#raytest

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

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

                              If you are trying to get a picked_point onto a 'plane' you use point.project_to_plane.
                              If you are mimicking the 'Rotate Tool' then before you get to that step you will pick a center_point [which is by definition on that plane].
                              You will next set the axis/normal for the rotation [which is a vector needed to define the plane]...
                              You define a plane as plane=[center_point, normal_vector]...
                              So now you have everything you need to project the next picked_point onto that plane... πŸ€“

                              When you take a mouse_click event the returned view inputpoint can be used to return a Point3d [ip.position] AND with a view pick_helper an entity type [or even types using several pick_helpers] - e.g. an edge or a face.
                              If your code somehow destroys the inputpoint [?] then clone it with a 'copy' before hand and use the copy in your second bit of code...
                              So you can click and return a point in the model and object(s) at that point.
                              A bit of simple math will transform that point onto a predetermined 'plane' as explained above...

                              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