Selecting 3 Point Arc Tools in Ruby on Mac

arctool
send_action

#1

The good ol’ “2 Point Arc” tool (formerly just called “Arc”) can be activated using “Sketchup.send_action(“selectArcTool:”)”

What now is called the “Arc” tool in the UI can be selected with “Sketchup.send_action(“selectArc3PointTool:”)”. This tool is referred to as “Arc3PointTool” by the RoolsObserver as well despite the UI having another tool called “3 Point Arc”.

The tool the UI calls “3 Point Arc” and ToolsObserver calls “Fit3PointArcTool” is the one I’m having troubles selecting. I can’t find any documented way to select it; it doesn’t seem to be mentioned by any name in the #send_action docs.

However I’ve noticed that the list of Windows only integer arguments for #send_action matches the tool_id returned by the ToolsObserver. Using this value does activate the tool on Windows! I’m afraid though it won’t work on Mac since the docs specifically says integer arguments are Windows only.

Does anyone have any ideas how to activate this tool on Mac? Perhaps it has there is a string identifer for send_action that is just missing in the docs?

Btw, the tool_id value for this tool is not present in the list in the ToolsObserver page. Should I add it? @tt_su


#2

The way to find obscure send action strings, is to create a keyboard shortcut, and then use the Registry Editor to examine the “Settings” key, and find the new shortcut attribute just set.

So I created a “SHIFT+A” shortcut to “Draw/Arcs/3 Point Arc” and then looked at what SketchUp created for a “Settings” attribute value. It is:

0 0 1 A selectArc3PointFitTool:

So then (at the Ruby console) I try:

Sketchup::send_action( "selectArc3PointFitTool:" )

… and I get a true response and the active tool changes.


#3

@slbaumgartner, so Steve does it also work on Mac ?


#4

I’m away and just on my phone now. I’ll have to look later.


#5

That’s a really neat method!

Thanks!

I think I can quite safely assume it’s the same on Mac but it doesn’t hurt if someone checks. :slight_smile:


#6

Just tried it on Mac - SU 2017, El Capitan.

Returns ‘true’ but the active tool doesn’t change. Sorry.

PS. Where would I look for a plist with the equivalent to Windows Registry entry for a shortcut?


#7

Ouch :frowning:

Does the other ones like this work?


#8

No, that doesn’t work either.

But Sketchup::send_action("selectLineTool:") does.

EDIT>: I was wrong.
Sketchup::send_action("selectArcTool:") DOES work - it needed another click in the main window to get the tool started.

Let me retry the Arc3Point one again…

No, that STILL does NOT work.

EDIT 2:
Dan’s example used Sketchup::send_action.

Your example used Sketchup.send_action("selectArcTool") ( full stop/period instead of double colon) and I copied it - that does NOT work.

But when I replace the . by :: it does.

However, the Arc3Point version still doesn’t.

EDIT 3:
Neither does Sketchup::send_action("selectFit3PointArcTool:")

EDIT 4:
HOORAY, I’ve found a version that does!
Sketchup::send_action("selectArc3PointTool:")


#9

I don’t have a WIndows machine capable of running SU 2017.

Does Sketchup::send_action("selectArc3PointTool:") also work on Windows?

Seems something close to a bug - at least in the documentation - if a slightly different name is used for the tool in Windows compared to Mac, and confusing at the least that different functions use different strings for the tool name.


#10

It works but it’s a different tool :confused: . That is the tool that is called “Arc” in the UI.

Regarding :: and . most style guides says :: should only be used for constants. It’s very odd if this changes how methods are called :open_mouth: .


#11

Yes, it does, BUT, … as said in the OP, it activates the “old” center and 2 Point arc tool, not the new one.

FYI, functionally, using the scope operator (::) instead of a period is just a preference. I use the scope operator when calling class methods or module functions, and the period when calling instance or singleton methods on instance objects. (It’s just how I learned, and I like the distinction.)

It does not.

Re (off-topic) style guides ...

I haven’t seen this in, ie “most style guides”. Then I don’t care for 99% of them.
My opinion of most style guides is that they are mostly full of subjective preferences and my subjective style preferences are usually different. So I do not care for most of the “rules” in most of the guides, as they just push a certain person’s preferences that often come from other coding languages. My main “rule of thumb” is, the style “rule” must make the code more readable and maintainable. So, most style guides can be halved by getting rid of the frivolous “control freak” nitpicky rules.

I absolutely pay no heed to any rule, that is not accompanied by a reason that makes sense. A reason “just so we all do it the same” is not a good reason.

So I give not much weight at all to arguments like: “most coding style guides” or “such and such style guide” says …


#12

Yes, you’re right - I don’t use the three Arc tools often enough to remember the appearance in use.

The last one I tried does indeed give the wrong tool - sorry, and I didn’t pay enough attention to what you/Dan had said earlier.

I was working in too much of a hurry, and eating at the same time so distracted. Changing the example back from :: to . with the selectArcTool example DOES work, but I’m pretty sure it didn’t the first time I tried it.


#13

Still interested @DanRathbun to follow this up, if it would help work out what to call the tool on Mac.


#14

There is considerable room for confusion on the Mac because the naming isn’t consistent or clear. In the prefences->shortcuts window the commands are all named by their path on the SketchUp menus. The strings to send to Sketchup.send_action() correspond (I think) to the Objective-C methods that activate each Tool in the Mac binary. I’ve verified that all of these work.

Menu path => send_action string

Draw/Arcs/Arc => "selectArc3PointTool:"
Draw/Arcs/2 Point Arc => "selectArcTool:"
Draw/Arcs/3 Point Arc => "select3PointFitArcTool:"
Draw/Arcs/Pie => “selectArcPieTool:”

On the Mac your current SU 2017 shortcuts are kept in

~/Library/Application Support/SketchUp 2017/SketchUp/Shortcuts.plist

The Shortcuts.plist file is xml with three entries for each shortcut: the letter key (string), the modifiers code integer), and the send_action (string). The modifiers code is a sum (or bitwise or) of flag values for the modifiers (the command key isn’t actually legal in user shortcuts, it is hard-wired to menu-defined ones and I am not sure what happens if caps lock is on):

0x010000 = 65536 = caps lock key
0x020000 = 131072 = shift key
0x040000 = 262144 = control key
0x080000 = 524288 = option/alt key
0x100000 = 1048576 = command key


#15

Thanks, Steve. So the tool name is different on Windows and Mac. That seems a bit careless, and confusing to boot.


#16

It’s the same on Windows. The UI name differs from the send_action name (which also differs from the ToolsObserver tool_name name). However what I can see there’s no difference between Win and Mac here. My guess is that the devs hade one working name that was changed in the UI before the it was published but the working name stayed in the code.

Thanks all!

Edit: Oops. They do differ between Mac and Win :open_mouth: . I didn’t read carefully enough.

Win is “Sketchup.send_action(“selectArc3PointFitTool:”)”.
And Mac is apparently “Sketchup.send_action(“select3PointFitArcTool:”)”.

That is a bit odd:| .


#17

Not quite true, if the name is different between Windows and Mac for the same TYPE of name - send_action in this case. Most aren’t different.


#18

That is indeed odd and idiosyncratic! I rechecked, and the string on Mac is indeed “select3PointFitArcTool”. If I’m right, the names on the Mac are the names of Objective-C methods, whereas on Windows they are just strings to match and convert to the number codes. I suspect that someone accidentally rearranged the name when translating from one to the other.


#19

This topic was automatically closed after 91 days. New replies are no longer allowed.