Trigger interface update efficiently

Trigger interface update efficiently

george.sladkovsky
Contributor Contributor
1,385 Views
4 Replies
Message 1 of 5

Trigger interface update efficiently

george.sladkovsky
Contributor
Contributor

Hello everyone!

 

Is there a way to efficiently update custom menu (UI) continuously?

Right now I'm using a few scriptJob commands to do this but is there a faster/safer way?

 

scriptJob -e "SelectionChanged "updateInterface()";
scriptJob -e "Undo" "updateInterface()";
scriptJob -ac "persp.translateX" "updateInterface()";

As you can see I've attached a scriptJob to perspective camera movement, change of selection and undo command to update UI. It has built in timer, so it will only update once every second and it's not slow, but for me it still looks very inefficient.

 

MEL or Python examples are very much appreciated. Thanks!

 

0 Likes
Accepted solutions (1)
1,386 Views
4 Replies
Replies (4)
Message 2 of 5

kevin.picott
Alumni
Alumni

There's a bit of a conflict in what you're looking for - continuous updating, and efficiency. The best you can do is what you have there, updating only when things your custom UI is interested in are modified. There shouldn't be a need for timer as that goes against the "continuous" part of your requirement. If you don't know or don't have access to the exact conditions that will require a change to your custom UI then you would use the "idleEvent" flag and the timer to update on a regular interval.



Kevin "Father of the DG" Picott

Senior Principal Engineer
0 Likes
Message 3 of 5

george.sladkovsky
Contributor
Contributor

Thanks! So scriptJobs and triggers built into procedures is the best way after all. Good to know!

0 Likes
Message 4 of 5

zewt
Collaborator
Collaborator
Accepted solution

FYI, in Python you can generally get better access using APIs like MNodeMessage.addAttributeChangedCallback and MDGMessage.addNodeAddedCallback.  Most of the scriptJobs you're using are just simplified interfaces to a few of those.  In general you also don't need to monitor undo, since if your listeners are set up correctly, you'll just see undo as another change that will trigger your listeners.

 

 

Message 5 of 5

george.sladkovsky
Contributor
Contributor

Thank you! I was meaning to switch to Python but never had the need for more advanced API access until now.

0 Likes