Populating dropdownlist

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
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

Alright

Thanks Anubis, I'll be sure to look into using this instead of the callback I was using before.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

just a tip

Goin in that way (using the General Event Callback Mechanism)
you should add more callbacks:
#nodeCloned - to catch cloned objects too
#sceneNodeAdded - 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.

-- shortly...
rollout foo "..."
(
	local callbackItem
	fn cbFn ev nd = ( ... )
 
	-- ...
 
	on foo open do (
		callbackItem = NodeEventCallback mouseUp:true \
		delay:1000 added:cbFn deleted:cbFn
	)
	on foo close do (
		callbackItem = undefined
		gc light:true
	)
)

my recent MAXScripts RSS (archive here)

JokerMartini's picture

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
)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

Got it. The rollout () were

Got it. The rollout () were wrong.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.