ScriptSpot

Forum topic · General Scripting

For Loop Collect Array

By jeremiah_bigley · 2013-01-22

Description

Hey guys I am having issues with trying to collect this array for a listbox.

for o in 1 to 3 where (selection[1].INodeBakeProperties.getbakeelement != undefined) collect (selection[1].INodeBakeProperties.getbakeelement o).elementname)

it errors if there is no bake element on the next loops... So I added a try()catch() and it gets rid of the errors but I get a bunch of undefineds in my array.

#("NormalsMap",undefined, undefined)

Also the try()catch doesn't seem to be working in my listbox.

for o in 1 to 3 where (selection[1].INodeBakeProperties.getbakeelement != undefined) collect try((selection[1].INodeBakeProperties.getbakeelement o).elementname) catch()

Idealy I just want to end up with a list for my listbox that looks like
#("NormalsMap")
or
#("NormalsMap", "Normalsmap")

Any help would be greatly appreciated.

Comments (2)

.numBakeElements()

jeremiah_bigley · 2013-01-22

nvm! Sorry guys... I hate when I figure something out right after posting...

.numBakeElements()

barigazy · 2013-01-22

Bravo !!! ;)