ScriptSpot

Forum topic · General Scripting

Classes??

By Shade926 · 2013-04-10

Description

How would i find the CLASS of a selected object

How would i find the PARENT CLASS of a selected object

And how would i Apply a class-specific action to all valid objects in a scene.

If you can answer any it would be a great help

Also what is a class specific action

Thanks?

Comments (4)

br0t · 2013-04-10

you need to print the value that "classof selection[1].parent" returns like


c = classof selection[1].parent
print c

And you need to start to read mxs help even more ;)

barigazy · 2013-04-10

Try now

try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "• • •"
(
button classbutton "Find Class Of Selected Object" width:190 pos:[5,5]
button classparentbutton "Find Parent Class Of Selected Object" width:190 align:#left pos:[5,30]
on classbutton pressed do
(
if selection.count == 0 then messageBox "Select some objects!" else
(
for o in selection do format "ObjectName: % ; ObjectClass: %\n" o.name (classof o)
)
)
on classparentbutton pressed do
(
if selection.count == 0 then messageBox "Select some objects!" else
(
for o in selection do
(
if o.parent != undefined then
(
format "ObjectName: % ; ParentName: % ; ParentClass: %\n" o.name o.parent.name (classof o.parent)
)
else format "ObjectName: % ; ParentName: -- ; ParentClass: --\n" o.name
)
)
)
)
createDialog bgaRoll 200 55 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

Shade926 · 2013-04-10

Im not getting back any feedback within the listenr am i meant too?

This is part of my code:

)
button classbutton "Find Class Of Selected Object"
on classbutton pressed do
classof selection[1]

button classparentbutton "Find Parent Class Of Selected Object"
on classparentbutton pressed do
classof selection[1].parent

)
createDialog test_button 500 500