I need to populate a dropdown list with all the scene cameras. Which that part is simple.
But the problem I'm coming across is if someone creates a camera after the dialog has been opened. What do you guys thing would be the best way to re-populate the dialog?
My first thought is a selection callback function.
Here is the base of the script so far.
(
camArray = for i in cameras where superclassof i == Camera collect i.name
rollout drop_roll "Drop Down List"
(
dropdownlist obj_dd "Objects :" offset:[0,-20] items:camArray
)
createDialog drop_roll
)
By
Comments (4)
Comment policy
Alright
Thanks Anubis, I'll be sure to look into using this instead of the callback I was using before.
just a tip
Goin in that way (using the General Event Callback Mechanism)
you should add more callbacks:
- to catch cloned objects too
- to catch merged objects
In the new NodeEventCallback (added in Max 2009)
you can do this with 1 callback,
and its more precise - catch even undo/redo operations.
callback on node create
Not sure why this isn't working..
Once i get this working I'll add a nodeDeleted callback as well.
(
global drop_roll
camArray = for i in cameras where superclassof i == Camera collect i.name
rollout drop_roll "Drop Down List"
(
dropdownlist obj_dd "Objects :" offset:[0,-20] items:camArray
fn fnUpdateCamList =
(
print "cool"
camArray = for i in cameras where superclassof i == Camera collect i.name
drop_roll.obj_dd.items = camArray
)
)
on drop_roll close do (callbacks.RemoveScripts #nodeCreated id:#camUpdate)
on drop_roll open do
(
callbacks.addScript #nodeCreated "drop_roll.fnUpdateCamList()" id:#camUpdate
)
createDialog drop_roll
)
Got it. The rollout () were wrong.