View Full Version : Automatically run a script upon selecting a specific object?
CalQdeX 11-13-2006, 08:15 AM I am working on a character rig.
I would like the Animator to be able to select a visual rig control that automatically switches selection to another object.
I need this for simplicity and maintaining a hierarchy that allows for maximum manipulation.
Thank you for any help in advance.
- Matthew
|
|
misterdi
11-13-2006, 11:43 AM
Using visual to drive control selection really sound like synoptic to me. Have you check the synoptic view?
Regards,
CalQdeX
11-13-2006, 11:58 AM
Yes I have a synoptic already set up for it, I can easily set up what I described within it but I would also like to have it work when the Animator selects the visual rig control directly from the user view. I would assume I would have to set it up as a property on the visual control but I don't know.
Thank you for your suggestion Misterdi.
misterdi
11-13-2006, 12:35 PM
Then you need to use event, i think it should siOnSelectionChanged event.
Just be careful not to bog down your system since it will required some resources for that.
I think you could use the wizard to create template for you.
To Create a self installed event use Plug-in Manager->File->New->Event and in the Event Definition Tab, checked siOnSelectionChange.
The default callback from siOnSelectionChange event is “siOnSelectionChangeEvent_OnEvent”.
Do what ever you want to do with this callback.
Regards,
CalQdeX
11-14-2006, 10:58 PM
Thats what I needed, Thanks a lot for the help, you saved the day!
Atyss
11-15-2006, 12:38 AM
If I could suggest something.....
First, I would avoid using seuch events. The reason is that everytime someone selects something, no matter what is the selection, the project, or whatever, the event is triggered. If you rely a lot on such mechanisms, it means that a single event will have to run a lot of code to make sure it knows what it's doing. For example it will have to find what is the project you're working in (by project I don't mean the XSI project, I mean client project), if the selected object(s) have the proper name, is the proper type, things like that. For instance, what if the behavior of the event has to be different with every character, and more different with every project, and the user is switching projects on a daily basis? Nightmare ahead.
As an alternative, I'd rather make the object unselectable (you can use groups or set the selectability at the object level), or completely hide the object from the user (using the SetCapability function). In-place of a "hidden" object, I would provide another object that I REALLY want the user to use, no other object.
My two little cents
Bernard
ThE_JacO
11-15-2006, 03:28 AM
the point about overloading the system is valid only up to a certain point.
the event will be triggered at every selection (it always is anyway), and if you cram it full it will affect performance.
the same point though becomes -entirely- moot as soon as you look past your nose in terms of implementation.
all you need is a property on the rig, something like "monitor selection", which is off by default.
your onselection event first checks that property, if it's false it won't do a thing, which means no overhead, if it's true then it will change the selection.
the same property is also important for maintenance, as it means you can keep the event live at all times and just turn one option off when you actually need to operate on thaose items, and you don't want the selection jump.
the other points in question, like making it unselectable or using a synoptic aren't alternatives really, as they don't fullfil the same needs and do not have any on-screen feedback, so don't let them dissuade you from using an in-viewport interface.
Plan it carefully (in terms of naming and placement of the property), make it flexible, and you'll shut up those pesky animators ;)
Once you get comfortable with it you can start exploring more in terms of optimizing it and structuring the interaction and the conditionals/flow
CGTalk Moderation
11-15-2006, 03:28 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.