W.A.S.P., Marco Plouffe (3D) A New Dawn, Fabricio Moraes (3D)

View Full Version : Selection

09-02-2009, 05:55 AM
1.How do I detect if selection array is empty, contains one element or it has an array of elements.

$.getcount -- gives an error if selection is empty.
$ --is the object if only one object and $.count fails

So it seems that $ is either a varaible or also a array.
How to handle these exceptions.

09-02-2009, 06:27 AM

09-02-2009, 07:17 AM
Thanks for reply.
Is it possible to detect if object is array or a varaialble.

09-02-2009, 08:05 AM
the "$" its the same as to write "selection"

but you can use it as prefix to select objects:
select $b* -- that will select every object witch name starts with "b"

I think, in this case the difference between variable or array isnt to big

- If ony one object is selected then "$" is this object (like a variable)
- if many objects are selected, then "$" its the array for this objects

try this on the MAXScript Listener

aa = Box() -- create a box
select aa -- select the box AA
$ -- check your selected object
$ as array -- try to look into the selection / array
bb = Box() -- create a box
selectMore bb -- add the box BB the your selection
$ -- check your selected object
$ as array -- try to look into the selection / array

you would get this on the listener window

$Box:Box01 @ [0.000000,0.000000,0.000000] -- your box AA
OK -- confirm for select command
$Box:Box01 @ [0.000000,0.000000,0.000000] -- your selection $
-- Unable to convert: $Box:Box01 @ [0.000000,0.000000,0.000000] to type: Array -- in this case (1 object) its a variable
$Box:Box02 @ [0.000000,0.000000,0.000000] -- your box BB
OK -- confirm for select command
$selection -- your selection $
#($Box:Box01 @ [0.000000,0.000000,0.000000], $Box:Box02 @ [0.000000,0.000000,0.000000]) -- your array (many objects)

one object:
$.name = "myname" -- you use it as a variable

two objects:
for i in $ do -- its an array and you have to loop into it
i.name = uniquename "myname"

I dont know it theres a way to check it its a selection or array, but in this case "$" I dont kwno if you really need it, in the script you woldu prefer to name your variables with a unique name.
I hope it helps you a little.

09-02-2009, 09:15 AM
Gotit. Thankyou.

CGTalk Moderation
09-02-2009, 09:15 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.