PDA

View Full Version : Scripting issue


JohnnyGogo
11-05-2009, 11:22 PM
I'm trying to script a tool for my rigging, such that I can predefine how I want my rig objects to move and when I select them it will change between the move and rotate tools and view and local modes.

The scripts in the rollout that defines how the objects move works fine, and so does the tool switching script. The problem is that I can't figure out how to run the tool switching script when I select an object.

Here's what I have so far:



(
rollout MotionTyper "Motion Typer" width:160 height:224
(
button btnSetMove "Set Move" pos:[8,56] width:139 height:31
button btnSetView "Set View" pos:[8,136] width:139 height:31
button btnSetLocal "Set Local" pos:[8,176] width:139 height:31
button btnSetRotate "Set Rotate" pos:[8,96] width:139 height:31
label lblCaption "Set MotionType" pos:[40,24] width:80 height:16
on btnSetMove pressed do
(
if $!=undefined then

(

setUserProp $ "motion" "move"

toolmode.commandmode=#move;

)
)
on btnSetView pressed do
(
if $!=undefined then

(

setUserProp $ "type" "view"

toolMode.coordsys #view

)
)
on btnSetLocal pressed do
(
if $!=undefined then

(

setUserProp $ "motion" "local"

toolMode.coordsys #local

)
)
on btnSetRotate pressed do
(
if $!=undefined then

(

setUserProp $ "motion" "rotate"

toolmode.commandmode=#rotate;

)
)
)

--HERE'S THE TOOL SWITCHING CODE.
--I HAVE NO IDEA ON HOW TO MAKE IT RUN WHEN I SELECT AN OBJECT.
(
if $!=undefined then
(
if getUserProp $ "motion"=="move" then

(

toolmode.commandmode=#move;

)

if getUserProp $ "motion"=="rotate" then

(

toolmode.commandmode=#rotate;

)

if getUserProp $ "type"=="local" then

(

toolMode.coordsys #local;

)

if getUserProp $ "type"=="view" then

(

toolMode.coordsys #view;

)
)
)
createDialog MotionTyper
)

Mathieson
11-06-2009, 12:33 AM
Look up callbacks in the MAXScript reference. You can use #selectionSetChanged from the general event callbacks or selectionChanged from the node event callbacks. I am starting to really like the node event systems and would suggest playing around with them.

Also, this thread should probably have gone in the MAXScript sub-forum (http://forums.cgsociety.org/forumdisplay.php?f=98) instead. I'm sure you would be able to get more help there.

JohnnyGogo
11-06-2009, 12:33 AM
EDIT: Oh, I'm sorry, I didn't even see your post. I'll try that. Thanks for showing me the way to the Maxscript forum, I couldn't find it.

EDIT: Thank you. I finally got it to work.

CGTalk Moderation
11-06-2009, 12:33 AM
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.