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

    Finding the cursor position?

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 6 Posters 2.8k Views 6 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.
    • W Offline
      Wacov
      last edited by

      Sorry if it seems like a stupid question, I just can't find out how to retrieve the cursor's coordinates on the screen. From the API, it looks like you can only get them using a tool, but all I want to do is punch something into the ruby console to get the cursor's coordinates, then get an infrenced point3D from that. Any help is appreciated 😄

      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

      1 Reply Last reply Reply Quote 0
      • K Offline
        ktkoh
        last edited by

        utilitiestools.rb has a tool called Query that will show you the coordinates of any selected point. Don't know where I downloaded it from.

        Keith

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Wacov, you need to create a tool class, then instantiate it as a tool, then figure out the cursor location from there. So it is not exactly as easy as one would wish.

          And the query tool ( located in Tools > Utilities > Query Tool ) is a great way to get 3d positions, using an already built tool. It comes with the SketchUp installation. It is a script that is useful for people trying to learn how to make a tool class script, just like you would be needing.

          So is the existing query tool enough? Or are you going to attempt to write your own?

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • W Offline
            Wacov
            last edited by

            The query tool should be fine, thanks for the help. I can't belive I didn't see that 🤣

            Out of interest, why is getting the cursor position only possible from in tools? Shouldn't there be global access?

            http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

              You are always using a Tool when using Sketchup, and everything is a Tool. A "Global access" state does not really exist - since there is always an active tool, you need a separate tool (the query tool) to get the cursor position. Alternatively, you can rewrite each of the current tools to support reporting the cursor position.

              Hi

              1 Reply Last reply Reply Quote 0
              • Al HartA Offline
                Al Hart
                last edited by

                @wacov said:

                Out of interest, why is getting the cursor position only possible from in tools? Shouldn't there be global access?

                We have some situations where we want to get the cursor position after a right click on an object, and executing a right click menu command. For example, a user rights click on a component, but we want to identify which face or material in the object the cursor is actually over. (I don't want the user to have to drill into the component to identify the face under the cursor.)

                Can the query tool be used in some way after a right click, but without further user input, to get the cursor location?

                Al Hart

                http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                IRender nXt from Render Plus

                1 Reply Last reply Reply Quote 0
                • W Offline
                  Wacov
                  last edited by

                  @jim said:

                  A "Global access" state does not really exist - since there is always an active tool, you need a separate tool (the query tool) to get the cursor position. Alternatively, you can rewrite each of the current tools to support reporting the cursor position.

                  The thing is, I'm scripting for SketchyPhysics. My old problem was solved with the query tool, I just needed a few 3D positions to make a route for AI I'm testing, but this has got me thinking about what I could do with the cursor. I'm guessing activating a tool in any way would end the simulation (which is a tool itself), and while modifying SP might work for me, it wouldn't for anyone else trying the model. So is it just impossible?

                  http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

                    Isn't it possible to tack up tools? http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tools.html#pop_tool

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

                    1 Reply Last reply Reply Quote 0
                    • W Offline
                      Wacov
                      last edited by

                      Huh... does that let you have multiple tools active at once?

                      http://sketchup.google.com/3dwarehouse/cldetails?mid=3096a836877fb9af6cd8ad826e9017b8&prevstart=0

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

                        Not at once, but stack them up. I think. I've not used the feature. Maybe the tools have to implement the suspend and resume methods...

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

                        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