Finding the cursor position?
-
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
-
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
-
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
-
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?
-
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.
-
@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?
-
@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?
-
Isn't it possible to tack up tools? http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tools.html#pop_tool
-
Huh... does that let you have multiple tools active at once?
-
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...
Advertisement