Yea. Okay. My example just to show how to activate the built in tool.
The SandBox is delivered as a custom tool, I don’t know a method to select it from Ruby. But I’m almost certain that you can not pass a parameters or objects to it… (nor to built in tool)
The built in tools are programmed to be controlled interactive by the GUI, not by Ruby code. The Ruby API provides primitive operations from which you can usually accomplish the same result from your code though it requires a pretty good understanding of the API.
Command IDs are only valid for a session. They are not persistent between sessions.
Also the nature of context menu commands is that their IDs are only valid whilst the context menu is displayed. Afterward the IDs are recycled and might be different the next time a context menu is “built”.
Try this (which would only work for English distro) …
AddDetailCmd = nil
break AddDetailCmd = o if o.menu_text == "Add Detail"
ADD: If the Sandbox Tools extension is not loaded, then the add_detail method above would active the SelectionTool.
Thanks for the help.
I tried your code but the same occurs.
The tool is activated (I can tell because the selection tool deactivates and the name of the tool appears when I use pop_tool) but no actual addition of detail occurs.
Well I do not know much about the Sandbox Tools as they are encrypted and not open source.
Perhaps it only adds “detail” to objects that the extension creates ? (Extensions know what they create by attaching attribute dictionaries. So perhaps use one of the attribute inspector extensions to do some snooping ?)
We cannot say why as we do not have your test model or code and don’t know what you really are trying to do.
The API documentation for the Sketchup::Model#select_tool method indicates that it simply returns the model object although activating the tool argument, … so this part of your observation is expected.
I tested out the tool, was I did get this helper warning …
In practice you need two triangular faces as the tool’s cursor does not activate until you are over the shared edge of 2 triangular faces. EDIT: OH no, it WILL split 1 triangular face into 3 triangular faces.
… and after further testing, … I don’t know why now (as it worked yesterday,) but most of the UI::Command objects for the Sandbox extension are “hidden”. (I suspect some of the API reflection methods may be “tweaked” to be silent about them as this is a proprietary extension.)
Anyway I was able to get this to work …
AddDetailCmd = nil
if tb.name == "Sandbox"
tb.each do |cmd|
next if cmd == "|"
if cmd.menu_text == "Add Detail"
break AddDetailCmd = cmd
But you cannot select the command from the Ruby Console because the console window has focus.
So I added a context menu item …
Thank you so much for your help Dan.
The code you provided does work but I agree that using the context menu item defeats the purpose.
I will attempt to create my own tool and will report back if I am successful.