Maxscript, speed up your workflow

Every day I get asked if a can whip up a script for this or a script that etc. More often than not I just walk over to the artist machine and do a very simple type in, maybe a few lines at most and that will solve their problem. Now not that I mind walking to someones desk to help them I thought I might take a second to discuss some ideas about manipulating large numbers of objects quickly, effectively and working on specific object types.  I really believe that scripting can empower artists, many artists shy away from scripting especially when there sitting next to a TD but a simple understanding of some simple scripting ideas can speed up an artists ability to work.

I do not intend this to be a introduction to scripting. I just want to show you how you can manipulate objects quickly using simple loops, basic conditional statements and the max script listener.

For Loops

Loops are how we iterate over objects, numbers, arrays etc. I found the best explanation of it in the Maxscript help file, “The for loop iterates through a range of numbers, time values, or a sequenced collection of values, such as an array or object set.”

In this example we will be iterating over materials, a specific type of material. There are a number of way one can accomplish this you could simple iterate through sceneMaterials and check to see if each material is the correct class that you want, this however would be slow and unnecessary. Instead we are going to use the getClassInstances function that will return an array of objects of a given type. For exmaple:

getClassInstances Sphere -- This would return an array of every instance of a sphere in the scene.
getClassInstances VrayMtl -- This will return an array of every Vray Material in the scene.

It is very simple to use the array returned by getClassInstances() in a loop.
for i in (getClassInstances VrayMtl) do(print i) --This will print every Vray Material in the scene

So now that we can iterate a given type of object or “class” we really want to be able to do something with them. An important concept to understand is that when we loop through the returned array each item in the array as we move through it is stored in the variable “i”. Consider the following code:

for i in (getClassInstances Sphere) do(i.radius = 100)

That statement will set the radius of every sphere to equal 100. It does this by first collecting them using the getClassInstances() function and “moving” the variable “i” through the array where “i” is used to access the  radius property and set to 100. We could also do something a bit more interesting like set the radius of every sphere to be random. We will use the random function in this example to give us a random integer.
for i in (getClassInstances Sphere) do(i.radius = (random 25 100))
Now each sphere will have a random radius between the 25 and 100.

Unless you really wanted to create Spheres with a random radius lets move on and learn how to do something useful.

The Maxscript Listener

Using the listener you are able to record your “actions” so to speak. This is a very easy way to query a property that you may wish to manipulate in a script. For example you might want to turn off trace reflections on all V-Ray Materials. To do this open the max script listener (Maxscript -> Maxscript Listener or hit F11). Once the listener is open go to the Macro Reorder menu and enable the macro recorder.

Open Maxscript Listener Screen Capture

Select the Maxscript listener from the menu or hit "F11"

Maxscript Listener Enabled Screen Shot

Enable the macro recorder from the MacroRecorder menu in the Listener

If you now go and open the Material editor select a V-Ray Material and Turn off Trace reflections. Imediately you should notice that Listener updating, in this example it should read something like:

meditMaterials[1].option_traceReflection = off

In the above piece of code where are interested in everything after the “.”, meditMaterials provides access to the materials in the editor (another article for that).

Now using what we learnt in the section covering loops we can now go ahead an change every V-Ray material in the scene:for i in (getClassInstances VrayMtl) do(i.option_traceReflection = false)

How easy was that? As you can see simple type in expressions or loops can save you a great deal of time. Just to recap we very quickly went over using loops with the getClassInstances() function and using the listener to ascertain what property’s we need to change. If you have any question then please just post in the comments I will do my get back to ASAP. Also remember the maxscript help file is your friend it is a fantastic help, if you are having trouble of some of the more basic concepts I suggest you start there.

I hope that shed some light on some very simple scripts that you might be able to use. If you have an idea for a tutorial use this form, I am more than happy to tackle any challenges you have in 3d or 2d.



41 Responses to “Maxscript, speed up your workflow”
  1. Chris says:


    thanks for such a great website, like it alot.

    May I ask a cheeky question, do you know how or where I can find a script that allows you to select objects in your scene,
    and it copys the name of your object and pastes it onto your Material name.
    So its an automatic material namer.

    I have tried several times, but always fail, I am not a scripter and are obviously making simple scripting mistakes.

    thanks for any help you can give

  2. Dave says:

    This would not be hard to script. I will whip something up and post it.


  3. AHosking says:

    for i in geometry do( =

  4. Theda says:

    Quality articles is the secret to attract the visitors to pay a visit the site, that’s what this site is

    Also visit my weblog – web page (Theda)

  5. If you desire to take much from this paragraph then you have
    to apply such techniques to your won blog.

    Also visit my blog best carry on luggage

  6. I truly love your website.. Great colors & theme.
    Did you make this site yourself? Please reply back as I’m attempting
    to create my very own site and would love to find out where you got this from
    or what the theme is called. Thanks!

    Look at my weblog :: fat loss factor

  7. Hello there! Would you mind if I share your blog with my zynga group?

    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Cheers

  8. A common place that most people look is in the data entry field.
    Ad submission jobs are one of the most lucrative jobs online today
    and anyone from just about any country can do them successfully.
    There is no need to prepare a resume or to have to market yourself to several hundreds of companies just to get a low paying job.

  9. I am really impressed with your writing skills as well as
    with the layout on your blog. Is this a paid
    theme or did you customize it yourself? Either way keep up the nice
    quality writing, it’s rare to see a nice blog like this one today.

  10. Hi there, I read your blogs on a regular basis.
    Your writing style is awesome, kerep doing wha you’re doing!

    my blog :: Lace Front Tape

  11. Russ says:

    Hey There. I found your blog using msn. This is a very well writfen article.
    I’ll be sure to bookmark it and come back to read more of your useful
    info. Thanks for the post. I will definitely comeback.

  12. Organo Gold says:

    This is the right site for anybody who hopes to understand this
    topic. You know so much its almost hard to argue with you (not that I
    personally would want to…HaHa). You definitely put a fresh spin
    on a topic that has been discussed for decades.
    Wonderful stuff, just excellent!

    my web-site … Organo Gold

  13. obviously like your web site however you need to
    take a look at the spelling on several of your posts.
    Several of them are rife with spelling issues and I in finding it very bothersome to tell the truth nevertheless
    I will surely come again again.

  14. This is my first time go to see at here and i am really impressed to read all at one place.

    Here is my site; best skateboard decks

  15. Very rapidly this site will be famous amid all blogging and site-building users, due to it’s good posts

    Here is my web blog – best binoculars for the money

  16. Fastidious answers in return of this matter with genuine arguments and explaining
    all on the topic of that.

    Here is my page best car amplifier

  17. The solution is applying short exercises which you can carry out when there is an available time.
    Labradors are very intelligent and will learn tricks fairly quickly.
    If you absolutely can’t avoid having a distance between everyone, try using a smaller
    aperture. Don’t let this overwhelm you; you are discovering a whole
    new concept of the word “meal”. It needs a little bit of hard
    work for those who do it using the natural method; and
    a huge budget for those who opt to go with the invasive method (surgery).

  18. hi!,I really like your writing so so much! share we be
    in contact extra about your article on AOL? I require an expert in this space to unravel my problem.
    Maybe that is you! Taking a look forward to peer you.

    Have a look at my page … airless paint sprayer reviews

  19. Justine says:

    Awesome! Its genuinely remarkable paragraph, I have got much clear idea about from this article.

  20. Pretty nice post. I just stumbled upon your weblog and wanted to say that I’ve
    really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed
    and I hope you write again very soon!

    My site best curling wand

  21. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a
    comment is added I get four e-mails with the same comment.
    Is there any way you can remove me from that
    service? Appreciate it!

    my web blog :: pressure washer reviews

  22. This is my first time pay a visit at here and i am truly
    impressed to read all at one place.

    Also visit my web site: best stethoscope

  23. I love your blog.. very nice colors & theme.
    Did you design this website yourself or did you hire
    someone to do it for you? Plz respond as I’m looking to design my own blog and would like to know where
    u got this from. thanks a lot

    Also visit my site Toronto commercial lawyer toronto

  24. With havin so much written content do you ever run into any issues of plagorism or copyright infringement?
    My blog has a lot of unique content I’ve either created myself or
    outsourced but it looks like a lot of it is popping it up all over the
    internet without my authorization. Do you know any ways to help prevent content from being stolen?
    I’d really appreciate it.

    Feel free to visit my site; best windshield wipers

  25. Wow, marvelous blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site is excellent, as well as the content!

  26. Hello there, You’ve done an incredible job. I’ll definitely digg it and
    personally suggest to my friends. I am confident they will be benefited from this web site.

    Feel free to surf to my web-site …

  27. I’d should talk to you here. Which is not some thing I do!

    I like reading a post which can make men and women believe.
    Also, thanks a lot permitting me to comment!

    Here is my website: vigrx plus lelong

  28. Thanks for some other magnificent article. Where else could anyone get that type
    of info in such an ideal manner of writing? I’ve a presentation next
    week, and I’m on the look for such info.

    Feel free to surf to my weblog; is garcinia cambogia good for you

  29. There are two versions, one written in Python and one
    written in Objective C targeting i – OS. At present, it has become important for
    businesses to have their own apps and mobile websites.
    With email messaging helping people around the
    world stay in touch cheaply, quickly and constantly the Internet provides a useful service.

    My homepage: Lair Defense Dungeon ios hack download

  30. My brother suggested I might like this web site.

    He was totally right. This post actually made my day. You can not imagine simply how much time I had spent for this information! Thanks!

    Take a look at my page ::

  31. I always spent my half an hour to read this web site’s posts every day
    along with a cup of coffee.

    Here is my web site; garcinia cambogia formula and safer colon combo diet

  32. I know this site provides quality based articles or reviews and extra data, is there any other web site which offers these kinds of data
    in quality?

  33. Currently it sounds like Movable Type is the preferred blogging
    platform out there right now. (from what I’ve read) Is that
    what you’re using on your blog?

    Here is my page concrete driveway overlay in Ridge Wood Heights area

  34. Hey! This is kind of off topic but I need some help from an established blog.
    Is it very difficult to set up your ownn blog? I’m not verey techincal but I can figure things out pretty fast.
    I’m thinking about making my own but I’m not sure where to start.

    Do you have any points or suggestions? Many thanks

  35. I visit each day some websites and websites to read articles or
    reviews, except this weblog offers quality based posts.

    My web blog; expirienced decorative concrete walkways Whitney Beach Florida

  36. Sooner or later, Google will find all new spam methods. It has the
    highest ROI (Return of Invesment) in all advertisement channels.

    What Googlebot is looking to see in the Free Local Google Advertising Listings is quite another.

    my page: online dragon city game

  37. Dina says:

    Hi to all, how is the whole thing, I think every one is getting more from
    this web page, and your views are nice in support of new users.

  38. I’m extremely insplired together with your writing abilities and also with the structure
    for your blog. Is this a paid theme or did
    you modify it your self? Either waay stay upp tthe nice quality writing,
    itt is uncommon to see a great blog like this oone

  39. Hi this is kind of of off topic but I was wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I
    wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

    my web page :: watch anime romance

Check out what others are saying...
  1. [...] the rest here: Maxscript, speed up your workflow : Dave and Goliath – Sydney … Kategorien3D Animation Tags: 3D Animation, animation, goliath, leave, projects, sydney, [...]

  2. says:

    Maxscript, speed up your workflow : Dave and Goliath – Sydney based 3d Animation, Visual Effects and Visualization…

    Maxscript, speed up your workflow : Dave and Goliath…

Leave A Comment