ScriptSpot

Forum topic · General Scripting

Populating a listbox by objects types help

By alexmbr · 2007-02-12

Description

 

How can I populate a listbox with all items of a scene based on object types checkboxes, just like the "Select Objects" that shows when we press the "H" key?

 

Thanks

Comments (4)

Variant 1

nikolay tashev · 2007-02-13

rollout test "Populator" (

multilistbox lsx "Objects"

checkbox ch_sp "Spheres"

checkbox ch_cn "Cones"

on ch_sp changed thestate do

(

if TheState == true do

(

tmp_arr = #()

for o in objects do if classof o == Sphere do append tmp_arr o.name

lsx.items = tmp_arr

)

if theState == false do

(

tmp_arr = #()

for i = 1 to lsx.items.count do

(

n = getnodebyname lsx.items[i]

if classof n == sphere do append tmp_arr i

)

for t = tmp_arr.count to 1 by -1 do deleteItem lsx.items tmp_arr[t]

lsx.items = lsx.items

)

)

on ch_cn changed thestate do

(

if TheState == true do

(

tmp_arr = #()

for o in objects do if classof o == Cone do append tmp_arr o.name

lsx.items = join lsx.items tmp_arr

)

if theState == false do

(

tmp_arr = #()

for i = 1 to lsx.items.count do

(

n = getnodebyname lsx.items[i]

if classof n == Cone do append tmp_arr i

)

for t = tmp_arr.count to 1 by -1 do deleteItem lsx.items tmp_arr[t]

lsx.items = lsx.items

)

)

)

createdialog test


Well this is one way.. may be a li'l slow though...

..aut inveniam viam aut faciam..

alexmbr · 2007-02-13

Thanks, but what I meant is to populate it by these:

Constructors

objects -- all the objects

geometry -- the standard 3ds Max categories...

lights

cameras

helpers

shapes

systems

spacewarps

selection -- the current selection

How can test to see if an item is a geometry or lights or a camera?

Thanks

Martijn van Herk · 2007-02-15

Alex,

Check out the following functions in the online reference:

classOf

superClassOf

isKindOf

Select an object (a box in this example) and evaluate the following commands:

classOf $ -- returns Box

superClassOf $ -- returns GeometryClass

isKindOf $ Box -- returns true

Cheers,

Martijn 

alexmbr · 2007-02-15

Thanks.