CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-14-2003, 11:00 PM   #1
MartinAndersen
New Member
 
Join Date: Mar 2003
Posts: 18
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 !!!
__________________
Martin Andersen
www.3d-designer.dk | info@3d-designer.dk
 
Old 05-14-2003, 11:07 PM   #2
Bobo
Krakatoa Guy
 
Bobo's Avatar
Borislav Petrov
Product Specialist
Thinkbox Software
Vancouver, Canada
 
Join Date: Mar 2002
Posts: 5,323
Re: Maxscript (noob) question

Quote:
Originally posted by MartinAndersen
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






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...

Last edited by Bobo : 05-14-2003 at 11:13 PM.
 
Old 05-15-2003, 12:36 AM   #3
MartinAndersen
New Member
 
Join Date: Mar 2003
Posts: 18
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...

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
__________________
Martin Andersen
www.3d-designer.dk | info@3d-designer.dk
 
Old 06-03-2003, 03:45 PM   #4
Kramsurfer
Don't Know-it-All.
 
Kramsurfer's Avatar
portfolio
Keith R Morrison
Custom Tools Developer
Focus360
San Diego, USA
 
Join Date: Sep 2002
Posts: 426
$'Obj*'.ishidden=true

Will hide all objects with "Obj" as the first three characters of their name.

Enjoy
Keith Morrison
 
Old 01-15-2006, 04:00 AM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:24 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.