How to identify / change between radius and diameter type dimension?

Last night I checked for a send_action automation integer, but realized that it is only going to be active (usable) when that specific context submenu is being displayed. (I.e., the command ID is generated “on-the-fly” when the context submenu is opened.)

The fastest way to toggle between the states, is to select a radial dimension, open the Preferences dialog, switch to the Shortcuts panel, then filter by "Type" and assign a shortcut to each type. (This cannot be done with an extension as it is a user preference.)

But once a shortcut is assigned and extension can send keystrokes to the system to fire a shortcut.

I’ve posted many times in this category how to use the WSH’s SendKeys method.

Here is one …

Use the ruby code to simulate a mouse click on the sub-menu in menu - #7 by DanRathbun

.. and another …

How's possible to minimize an extension window? - #2 by DanRathbun

For now, … if you are coding toolbar buttons, your extension would need to tell the user to assign shortcuts, and then you’d either have them enter the shortcuts into an inputbox or see if you can snag it thusly …

def find_dim_shortcut(type)
  shortcuts = Sketchup.get_shortcuts
  shortcut = shortcuts.find {|combo| combo =~ /Edit\/Item\/Type\/#{type}\Z/ }
  return nil unless shortcut
  keychord = shortcut.split("\t").first
end

Ie …

dia = find_dim_shortcut('Diameter')
#=> "Ctrl+F12"

I as a test assigned “Diameter” to CTRL+F12.

So, for my machine to toggle to Diameter:

shell.SendKeys("^{F12}")`

Once you get the keychords, depending upon platform you can convert them to what is needed for SendKeys on Windows or perhaps an AppleScript command via system(). I remember that @john_drivenupthewall was very fond of using cliclick utility on Mac. There is also supposed to be a sendkeys-macos utility. Neither are likely to be natively installed. So AppleScript may be the best.