Send_action workarounds?
-
To enhance my workflow & minimize my pen/mouse movements in Sketchup, I'm working on a on-screen-menu tool (just like I used to have in my 3dsMax days 10+ years ago).
To launch plugins I use: active_model.select_tool ...
To launch Sketchup commands I use: send_action ...Several native commands are missing from the API-docs http://www.sketchup.com/intl/en/developer/docs/ourdoc/sketchup#send_action. Commands like boolean-union, subtract etc are missing. Is there a way to still invoke those methods?
-
Boolean operation methods are part of the API under Group/ComponentInstance classes.
The send_action method has always been a hacky way to invoke things. If you can do thing without it that is the recommended way to do so.
-
@tt_su said:
Boolean operation methods are part of the API under Group/ComponentInstance classes.
These methods need 2 solid objects. For union I could start a script from the onscreenmenu that starts the union-method after selecting 2 solid objects. But for subtract, how can one control which object will be the subtracting object with a pre-selection of two objects?
There's no way to simulate a normal mouse-press on the toolbar's union-button / subtract-button?
@tt_su said:
The send_action method has always been a hacky way to invoke things. If you can do thing without it that is the recommended way to do so.
Just to be absolutely sure: there's no way to start native commands with
active_model.select_tool
? -
@kaas said:
But for subtract, how can one control which object will be the subtracting object with a pre-selection of two objects?
http://www.sketchup.com/intl/en/developer/docs/ourdoc/group#subtract
The object that subtract is the object in the argument. You invoke the method on the object you want to keep.@kaas said:
Just to be absolutely sure: there's no way to start native commands with
active_model.select_tool
?Not sure what you mean by native commands. For native tools you do need to use send_action. I's one of them things where we should be introducing proper API methods to do so.
But for doing boolean operation you have full control with the API methods. -
TT, thanks for your reply. I ended up assigning some un-used keyboard shortcuts to boolean-union and some other methods. Now I can start these methods from my on-screen-menu by using
WIN32OLE.new("WScript.Shell").SendKeys("+u")
for instance. Maybe not the most pretty solution but as long as I don't buy a Mac it seems to works without any problem. -
I'm still confused to why you don't want to use the API methods? Simulating key strokes or mouse clicks seems convoluted. Does the API not produce the same result as the UI operation?
-
@tt_su said:
I'm still confused to why you don't want to use the API methods? Simulating key strokes or mouse clicks seems convoluted. Does the API not produce the same result as the UI operation?
It's not that I don't want to use the native API methods, it's just that I think it's more simple and easy to do it this way, just for an all-purpose on-screen-menu.
I will try to explain:
- The on-screen-menu(OSM) works just the same as clicking on any icon in one of the toolbars but in the OSM the 'icons' are centered at my mouse point at the moment I press the OSM keyboard shortcut. So with one keyboard shortcut, I can start several of my most used methods within a small mouse-movement-area.
I was thinking the most easy way to do this is creating 2 arrays: one for the all the 'names' in the OSM, and one array with the 'launch code' for starting the corresponding methods. Because there's no
Sketchup.send_action
option for boolean-union (and more), I needed another simple way to just start the method and let me pick some solids.I hope this makes more sense...
-
On the PC, send_action can process native tool command integer IDs.
I pub'd some IDs here (but do not use that file as is. It mods the API.) Just use it for tool ID reference. Somewhere here Thomas also posted a tool ID hash.
Ex:
Sketchup::send_action( 24201 ) # Union Tool
Advertisement