Use protractor in a custom tool?

userinterface
rotatetool
extension

#1

Hi,
I’m entirely new to developing SketchUp extensions. I started developing one just today because I found out I need to do something that would take several hours to do manually - so I decided to learn how to use the Ruby API.

However right at the begining I’ve got into trouble: I want to create a tool that would convert the ordinary Cartesian (XYZ) axes into cylindrical or spherical axes. As you need to define the center first, it would be appropriate to use the internal Protractor tool / helper / input thingy.

It would look something like this:

I know FredoScale uses it so there has to be a way to use it in an extension, but I’ve been searching through the Ruby API specs for an eternity and still haven’t found it!

I’m a newbie so I’d appreciate an example with a few lines of code, thanks! :slight_smile:


#2

You can only active the protractor tool using Sketchup.send_action()
But that will have precipitated you out of your own tool !

Fredo actually replicates the actions of the protractor tool in his own Tool, by using the view.draw commands to replicate the ‘gizmo’ form location, colors, tooltips, status-bar prompts etc.
This combined with guides etc, can then replicate the protractor tool’s functions within your own tool…


#3

You need to learn Ruby first. The SketchUp API only extends Ruby to work with models and SketchUp.

See the Ruby Learning Resources pinned wiki thread in this category.

Because the tool interface is advanced event driven programming.
Start with simple plugins, and progress from there.

Forget using internal “native” tools. Since the observer overhaul (v2016), tool state changes are all queued up and dumped enmass at the end of tool operation. It makes it near impossible to interact synchronously with native tools now.

As TIG said, Devs need to write their own tool functionality that mimics native tool flows.

The best way to learn is to read examples. The SketchUp team has a Line tool and Cylinder tool example in their “Examples” extension. Their “Utilities Tools” extension also has good examples.


#4

Thanks for not helping :wink:
I need the plugin to get the work done!
And I’m an advanced programmer and mathematician, so don’t depreciate me :slight_smile:

(I really don’t mean to be rude, I just want to say I’ve googled enough to know this.)

.

That sucks :confused:
And I guess there’s no chance of seeing Fredo’s code - it’s all encrypted, right?
Pfff, long live open source!

.

OK, I did already. Seems I’ve got to do without it.

Thank you anyway, gentlemen!


#5

How would I know ? … your profile says nothing.

It is a little late. It is best to say these things in the original post, so we don’t waste our time.

I only went by what you said which implied you were new to development, viz:

I myself, had over 30 years experience when I came to SketchUp and Ruby. But it meant nothing, because Ruby was all new. I could not make heads nor tails out of the first extension code that I tried to read. (And I already knew BASIC, Ada, object oriented Turbo Pascal and was previously certified in JavaScript.) It still took some dedicated time to go through basic Ruby tutorials. It was time well spent.

Yea, I spent hours “not helping” creating this just for those who are new
to Ruby and SketchUp extension development:


#6

Wow, the Wiki Lists are actually pretty cool!
Look, I really didn’t expect you’d be that offended. After all, there were smiley faces :slight_smile:
I’m sincerely sorry!


#7

Am not really. Just defending my position. :stuck_out_tongue_winking_eye: