Return the number of selected objects

Return the number of selected objects

Anonymous
Not applicable
258 Views
2 Replies
Message 1 of 3

Return the number of selected objects

Anonymous
Not applicable
Hello,
I trying to make a simple script to get the number of selected objects in the scene.
I have trying with that :

macroScript NbrObjectSelected category:"TestTools"
(
nbrObjects = selection.count
if (nbrObjects) == 0 then
messagebox "Please, select one or more object"
else
(
textNbObjects = nbrObjects as string
print "Objects selected = "+textNbObjects
)
)

It works not very good without the macroscript header : he print 1 "Object Selected =" (without the number
and another time with the number... strange.
And when I include the Macroscript header, it dosen't work, I have only "objects selected : "...
Anyone can help me ?
Regards.
0 Likes
259 Views
2 Replies
Replies (2)
Message 2 of 3

Steve_Curley
Mentor
Mentor
Print takes 1 (ONE) parameter only - your construct will be seen as 2 parameters.

a) print (“Objects selected = “ + textNbObjects) --note the parentheses
b1) format "Objects selected = %\n" textNbObjects to:listener
b2) format "Objects selected = %\n" nbrObjects to:listener --auto conversion of number to string

** to:listener is for completeness - it can be omitted (it's the default stream)

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 3

Anonymous
Not applicable
Ok, I have forget the parentheses !
Now It work fine.
Many thanks Steve.
Best regards
Nick.
0 Likes