PDA

View Full Version : Update UI based on selected object?


lxdengar
07-03-2007, 07:09 PM
Hi All,

I tried looking through the forum for this, but since search is busted again (whee!), I thought I'd ask the question.

I have a mel script which can create 3 particle systems. The systems can be created in the dialog by hitting buttons at the top, which in turn creates the system, or if it already exists, calls a getAttr proceedure.

examples of the type of behavior are:

1.) User clicks on the "Particle 2" button, which creates the Particle 2 set, then clicks the "Particle 1" button. The UI updates with the Particle 1 System's attributes.

2.) The user accidently closes the dialog and calls it again, and it updates with the system attributes.

I'm just unsure about how I can get the values found by the GetAttr statements back into the various fields and sliders within my UI (without calling an edit to each and every control). Is there a way to globally update the UI?

Thanks for helping out a UI newb.

isoparmB
07-05-2007, 10:05 AM
Sorry, but I think you'll have to call out an edit for every control. An easier way to do this though would be to write that function out as a procedure which gets executed by your button, so you won't have to input all of the -edit commands in the -command flag of your button and end up in a stringy mess.

azshall
07-05-2007, 04:05 PM
you could setup a scriptJob ... just gotta remember to kill it when you don't need it anymore...

Seth

ewerybody
07-06-2007, 08:53 AM
scriptjob is right
extra kill is wrong

you can attach your scriptjob to a UI via the -parent flag.
The job is automatically killed if you close your UI.

And I'd suggest to write a proc that creates your UI upon the values from a selection! I mean create your window and then run that proc. And make the scriptjob run that proc on selectionChange.

So the UI is initially right with the appropriate values. When you change selection the UI in the window will be deleted and rebuild with the right values again.

lxdengar
07-06-2007, 08:01 PM
Thanks everyone!

What I ended up doing was creating a proc which gets the attributes from the given system (just like above), and then calls a delete columnlayout, and rebuilds it (parented to the original window). This seems to work just fine.

This gets the correct attribute for all the correct controls, with the excpetion of some checkboxes (which are adding/deleting fields to the system). I guess I will have to do a check for each field type (vortex, newton, drag, etc) and see if it is dynamically attached to the system, and edit the checkbox on, if needed. That is - unless anyone has a cool trick.... :)




scriptjob is right
extra kill is wrong

you can attach your scriptjob to a UI via the -parent flag.
The job is automatically killed if you close your UI.

And I'd suggest to write a proc that creates your UI upon the values from a selection! I mean create your window and then run that proc. And make the scriptjob run that proc on selectionChange.

So the UI is initially right with the appropriate values. When you change selection the UI in the window will be deleted and rebuild with the right values again.

CGTalk Moderation
07-06-2007, 08:01 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.