[Closed] Maxscript (noob) question
what is the smartest way to handle a lot of objects… like hide them all with script???
something like this?::
array myObjects (“obj1”,” obj2″,” obj3″)
for myObjects +1 do myObjects hide
How do I do ??
dammit I’m not that hardcore scripter :thumbsdow !!!
Originally posted by MartinAndersen
[B]what is the smartest way to handle a lot of objects… like hide them all with script???something like this?::
array myObjects (“obj1”,” obj2″,” obj3″)
for myObjects +1 do myObjects hide
[/B]
Depends on where you get the objects from…
You can say
myObjects = #($Obj01,$Obj02,$Obj03 )
hide myObjects
If the names are accessible through a pattern, you can use wildcards like
hide $Obj*
Generally, you don’t need to loop through arrays when the function you want to use (like Hide) is “Mappable” – in other words, it loops internally over all objects when the argument is a list or collection of objects…
The correct format of FOR loop would be
for i in myObjects do hide i
or
for i in $Obj* do hide i
You can create an array (for later usage) by using “collect” instead of “do”.
myObjects = for i in $Obj* collect i
or
myObjects = $Obj* as array
There are 1000 ways to do things in MAXScript and all of them have their usage.
For example, you can filter objects by some property while collecting by using “where”
myObjects = for i in $Obj* where classof i == Box collect i
It will collect obly those objects with name “Obj*” that are boxes.
Please ask your questions if you have anything specific you want to achieve…
Thanks alot bobo, there is always a better way to do things, than my way… hehe first my code looked like this:
hide $object01
hide $object02
hide $object03
hide $object03
hide $object04
hide $object05
hide…etc.
That is kind of a stupid way to do it… :applause:
So I can just start learning the best ways now
This one is very good:
myObjects = #($Obj01,$Obj02,$Obj03 )
hide myObjects
Thanks a million times Bobo
$‘Obj*’.ishidden=true
Will hide all objects with “Obj” as the first three characters of their name.
Enjoy
Keith Morrison