PDA

View Full Version : Need a script that selects the tool mode


Scott Ayers
12-14-2007, 08:33 PM
Hey guys,

I'd like to be able to select an object in the scene and have the tool mode change to the rotate tool. So I don't have to do it by hand all of the time.

Is this possible?

Per-Anders
12-14-2007, 09:03 PM
It's not possible to make a script execute one tool, wait for you to finish using that tool and then select another tool for you. Perhaps it would be better if you learnt the keyboard shortcuts (or set them up how you wanted) then it's just a single button press away as you can either use the hotkeys to make selections without changing out of the current tool 8,9,0, or simply tap the shortcut for the rotation tool. For individual objects you can single click select anyway without needing any shortcuts when using any of the transform tools.

Kuroyume0161
12-14-2007, 09:40 PM
A C++ plugin could do this with SetAction() while checking for ActiveObject changes via a SceneHook - but it would be, as noted, a bit of a long way to go.

Scott Ayers
12-14-2007, 09:46 PM
It doesn't have to do all of that fancy thinking.
I only need the object to be permanently associated with the rotate tool.

Since you can access and manipulate the various tools through their ID# in COFFEE.
I was hoping there would be a way to write a COFFEE script to force the rotate tool to be selected when that object is selected.

Per-Anders
12-14-2007, 09:57 PM
Oh well you should be able to do that easily enough, just apply a script to the object that detects it's selected bit, and then chooses the rotate tool. Something like this (not tested)


var last_value;
main(doc,op)
{
if (op->GetBit(BIT_ACTIVE) != last_value)
{
last_value = op->GetBit(BIT_ACTIVE);
if (last_value) CallCommand(id of command you want to call);
}
}


This code makes it so that it only calls the rotate toolshte once when the selection actually changes. Apply that to a tag, replace the id of command you want to call with the id you need from the command manager and you'll be good to go.

You should also note that you can make cinema do this stuff automatically without and scripting via the Visual Selector, and the HUD (with an action in the rmb menu).

Scott Ayers
12-14-2007, 11:13 PM
Thanks Anders.
That seems to work pretty good.:thumbsup:

I applied a copy to my IK goal with the move tool as the ID.
And a copy to my hand rotation control object with the rotation tool as the ID.

So now when I double click on a controller in the scene. I get the correct tool automatically.
That's pretty cool.


Thanks for the help.

Scott Ayers
12-15-2007, 01:09 AM
Hmmm.

After testing this for a while. I'm finding that once in a while, clicking on the object won't activate the coffee script. And the tool mode won't change.
I still like it though. It has lots of potential.

It's also very finiky about how fast you double click on the object to work or not. Almost like the program needs a few milliseconds to process the first click then move on to processing the script on the secon click.
So I'm guessing that this could due to the script not refreshing properly?

Would some implementation of the "Object->Message(MSG_UPDATE);" help the script run better?

Sneaker
12-15-2007, 12:43 PM
By the way Visual Selector can do this for you.
-Michael

Scott Ayers
12-15-2007, 04:03 PM
IMHO. This is faster, and much more eligant variation on the VS tool.

It accomplishes the same task. But without needing to setup any tag or hud elements that clutter up the screen.
If you have more than one character in a scene. The various HUD elements really clutter up the screen.

For me. This is a much better workflow than the VS.

CGTalk Moderation
12-15-2007, 04:03 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.