Refreshing geometry while using move tool or rotate tool

Hello Ruby SU lovers,

I have developped a little sketchup script that compute lights ray reflexions on a face called reflector.
My script can compute the rays when I move/rotate the source light or the reflector but only after commiting the operation by using the method onChangeEntity of the class Sketchup::EntityObserver.

Now I want to go futher and compute the rays dynamically while the move tool or the rotate tool is active. Just like when I move an edge of a face and the face is changing its shape.

What the best way to do that ?

  • Can I extend the move tool and the rotate tool to add a call to my computing rays script ?
  • Or should I redevelop an entire new move / rotate tool and add reference to my script ? (what I hope note, I don’t want to reinvent the wheel !)

Thanks in advance for your precious help.

I’m afraid that you cannot extend the existing tools.

You have a ToolsObserver (http://ruby.sketchup.com/Sketchup/ToolsObserver.html), but I don’t think it’ll update for the mouse-events you are looking for.

You title says “Refreshing geometry while using move tool or rotate tool”. Even if you did have an event for mouse-move when the Move/Rotate tool you wouldn’t be able to modify the model. When you initiate Move or Rotate SketchUp starts an operation. While in the middle of an operation you cannot start a new one (of you do you stop the first one.)

If you want live update while the object is being moved rotated you probably have to create your own tools. If you are ok with deferring until the Move or Rotate have been completed you should be able to use the ToolsObserver.

Thank you TT for your quick reply.

I looked at the ToolsObsersver class and there is only one envent that don’t match my needs (onActiveToolChanged).

I agree with you everything happend in the mouse event of a new tool. If I can’t extend my new tool from the original move/rotate sketchup tool I will write my own. Do you have any advice or existing script so I don’t start from nothing ?

Exactly : I’m looking for a refreshing of the screen not a real time geometry changing (no changes made on entities before close and validate at the end of the tool). Like in a lot of Sketchup tools beetween the moment you active the tool and you commit the operation when you can move the mouse and previsualize the effect before commiting the action and then modifying effectively the geometry.
Here is my lack of knowledge : if it’s not geometry refresh, what is this ?

Thanks again for your precious help.

Afraid not. I did something similar for my own extension Vertex Tools - and realized how complex the Move, Rotate, Scale tools are. Unfortunately that isn’t a free extension so I cannot post the code as-is. I could look into extracting the core of it, but right now we’re really busy. :confused:

The SU core have more control over the viewport and rendering than the Ruby API. So it’s harder to replicate the functionality.
In one of my other extensions I have a custom PushPull tool - where I do try to modify geometry live, but it’s very difficult due to how entities are merged all the time. I’ve considered modifying it to using just view.draw instead - keeping it simpler and more reliable.

TT alludes to one technique that many Ruby extensions use to show an effect without creating actual geometry: the draw methods in the view class, which are invoked automatically when your tool is active and the view needs to be refreshed.

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