List of tools ID

Is there a list for all the tools? I know I can get info on the ID of the tools in the Ruby Console with

tools = Sketchup.active_model.tools
id = tools.active_tool_id

but some are ‘hard to get’ because they don’t need any interaction or can be activated ‘on the go’ (‘Zoom extents’ , ‘Zoom Previous’ etc.

Don’t worrie, I am not trying to write an extension, it’s part of my ‘Elementary’:

to give it some ‘weight’

Some are listed here …

I guess you will not get a Tool ID for ‘Zoom extents’ since this is not a Tool, just a command. It is executed and then it “disappears”.
While the “Select”, “Eraser” “Zoom Window”… is a real tool, it is aktív until you select an other one.
The “Orbit” is a little special, because it has an ability to suspended other tool when it is activated than resume the original tool when it is deactivated.

I’m not sure but there ara a Constants in a https://ruby.sketchup.com/top-level-namespace.html
and e.g.:

CMD_ORBIT
#>>10508
CMD_ZOOM_EXTENTS
#>>10527
1 Like

Yes the top level CMD constants are also valid tool and command IDs.
(But they only work on the Windows platform as send actions.)

It is actually the other way 'round. Tools IDs are really a subset of command IDs.

2 Likes

I guess I am lucky, I found a Cmd key on my Mac :wink:

Thanx, I will wrap up my list and get something like this

Quick code snippet
(Copy paste to Ruby console)

def get_const
  Module.constants.each {|k| 
    puts "#{k} : #{Module.const_get(k)}"  if k.to_s.include?("CMD")
  }
  return
end
get_const

Result:

CMD_PAN : 10525
CMD_MAKE_COMPONENT : 21083
CMD_DIMENSION : 21410
CMD_VIEW_ISO : 10507
CMD_VIEW_TOP : 10501
CMD_VIEW_FRONT : 10502
CMD_VIEW_RIGHT : 10503
CMD_VIEW_BACK : 10505
CMD_VIEW_LEFT : 10504
CMD_VIEW_BOTTOM : 10506
CMD_VIEW_PERSPECTIVE : 10519
CMD_POSITION_CAMERA : 21169
CMD_NEW : 57600
CMD_OPEN : 57601
CMD_SAVE : 57603
CMD_CUT : 57635
CMD_PASTE : 57637
CMD_DELETE : 21021
CMD_COPY : 57634
CMD_REDO : 57644
CMD_PRINT : 57607
CMD_PAGE_NEW : 21067
CMD_PAGE_DELETE : 21078
CMD_PAGE_NEXT : 10535
CMD_PAGE_PREVIOUS : 10536
CMD_PAGE_UPDATE : 21068
CMD_RUBY_CONSOLE : 21478
CMD_SKETCHAXES : 10522
CMD_SHOWHIDDEN : 21154
CMD_SHOWHIDDENOBJECTS : 21153
CMD_SHOWGUIDES : 21980
CMD_UNDO : 57643
CMD_DISPLAY_FOV : 21494
CMD_SHOWHIDDENGEOMETRY : 21155
CMD_SELECTION_ZOOM_EXT : 21469
CMD_LINE : 21020
CMD_POLYGON : 21095
CMD_MOVE : 21048
CMD_SELECT : 21022
CMD_PAINT : 21074
CMD_ERASE : 21019
CMD_RECTANGLE : 21094
CMD_CIRCLE : 21096
CMD_ARC : 21065
CMD_FREEHAND : 21031
CMD_PUSHPULL : 21041
CMD_TEXT : 21405
CMD_ROTATE : 21129
CMD_EXTRUDE : 21525
CMD_SCALE : 21236
CMD_OFFSET : 21100
CMD_MEASURE : 21024
CMD_PROTRACTOR : 21057
CMD_SKETCHCS : 21126
CMD_SECTION : 21337
CMD_DRAWOUTLINES : 21347
CMD_DRAWCUTS : 21348
CMD_ORBIT : 10508
CMD_DOLLY : 10523
CMD_ZOOM : 10509
CMD_ZOOM_WINDOW : 10526
CMD_ZOOM_EXTENTS : 10527
CMD_CAMERA_UNDO : 10529
CMD_WIREFRAME : 10510
CMD_HIDDENLINE : 10511
CMD_SHADED : 10512
CMD_TEXTURED : 10539
CMD_TRANSPARENT : 10513
CMD_WALK : 10520
``
1 Like

Actually you are right! (again :wink: )

And another similar way. (I prefer using Object as the top level is the ObjectSpace, not a “ModelSpace”.)

Object.constants.sort.grep(/CMD/) {|c| puts "#{c} : #{Object.const_get(c)}" }

Well again, I’ll have a little homework to understand that…


Your snippet is printing out at the end, an array with 69 times of nil. (same size as a constants with “CMD” in it)
Why is that?

Okay, I see… Enumerable.html#method-i-grep
and the block’s result is stored in the output array.

While the #each:
Returns the array itself.
(Then I forced to return nil and yours return the result also)

… and Kernel#puts returns nil.
I’d think most would want it to return the string as sent to STDOUT ?

Anyway if you want an array of the output strings, then remove the “puts” method call, and just build the strings in the block.

CMD_SKETCHCS : 21126

=Make Component!

weird name, from the early days, I presume, like CMD_SKETCHAXES

1 Like

periodiek_tools

Made for teaching purposes? Or?

__
BTW:
I just checked the
Sketchup.send_action(CMD_SKETCHCS)
It is initiate changing the axes in a current drawing context.

Sketchup.send_action(CMD_SKETCHAXES)
Will toggle the visibility of model axes.

1 Like

Not exactly
it is
Sketchup.send_action(CMD_MAKE_COMPONENT)
If no selected elements this “starts” similar than CMD_SKETCHCS
but it is really makes component (will be empty and set the drawing context into it)

If there is selected elements it will open the make component window.

If the selected element is a component will do nothing.