Problem with Callbacks's first start

Hello guys, first post here.

I'm a noob in scripting.

In a script I'm trying to write, I wanted to show in a listbox the objects's name of the current selection, but the first time I launch it it doesn't work (got this error: "Unknown property: "selectedobjs" in undefined"), then the next times it works.
What did I do wrong?

Thank you in advance guys

function SetupDropDownList = (
 
	sel_names_array= for obj in selection collect obj.name
 
	tmpArr = for grp in selection where isGroupHead grp collect grp
	numgroups = tmpArr.count as string
	numobjs = (sel_names_array.count - tmpArr.count) as string
 
	info_array=#(sel_names_array,numobjs,numgroups)
	return info_array
)
 
 
 
function RefreshList = (
 
	items_array = SetupDropDownList()
 
	MyRollout.selectedobjs.items = items_array[1]
	MyRollout.nselectedobjs.text = items_array[2]
	MyRollout.nselectedgrps.text = items_array[3]
 
)
 
 
 
rollout MyRollout "MyRollout"
 
(
 
group "Export List"  (
 
 
	listbox selectedobjs 
 
 
	label objtext "Objects Selected:" across:2 align:#left offset:[30,0]
	label nselectedobjs "objects"
	label grptext "Groups Selected" across:2 align:#left offset:[30,0]
	label nselectedgrps "groups"
 
	)
 
 
)
 
createDialog MyRollout 200 300
 
 
try(callbacks.addScript #selectionSetChanged "RefreshList()")catch()

Comments

Comment viewing options

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

.

global MyRollout
try(destroyDialog MyRollout)catch()
 
function SetupDropDownList = (
 
	sel_names_array= for obj in selection collect obj.name
 
	tmpArr = for grp in selection where isGroupHead grp collect grp
	numgroups = tmpArr.count as string
	numobjs = (sel_names_array.count - tmpArr.count) as string
 
	info_array=#(sel_names_array,numobjs,numgroups)
	return info_array
)
 
 
 
function RefreshList = (
 
	items_array = SetupDropDownList()
 
	MyRollout.selectedobjs.items = items_array[1]
	MyRollout.nselectedobjs.text = items_array[2]
	MyRollout.nselectedgrps.text = items_array[3]
 
)
 
 
 
rollout MyRollout "MyRollout"
 
(
 
group "Export List"  (
 
 
	listbox selectedobjs 
 
 
	label objtext "Objects Selected:" across:2 align:#left offset:[30,0]
	label nselectedobjs "objects"
	label grptext "Groups Selected" across:2 align:#left offset:[30,0]
	label nselectedgrps "groups"
 
	)
 
 
)
 
createDialog MyRollout 200 300
 
 
try(callbacks.addScript #selectionSetChanged "RefreshList()")catch()
obaida's picture

you need to define

you need to define Global/Local variables .

Comment viewing options

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