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.



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

  5. They also work hard to develop easy payment plans for their services.

    While Naphtha is not commonly discussed, it is a great alternative to butane and propane.
    There are also specialized in Singapore, foreign institutions that either have established offices here or have tie
    ups with local polytechnics, which allow polytechnic students to pursue a degree related courses after completing
    their degrees at polytechnics. The problem arises when the volume of the data increases with the
    integrations of tools and applications such as customer relationship management, supply chain management,
    e-mail, wireless computing, ecommerce, online store, workgroup collaboration, smartphone integrations and various other factors.

    For many retired persons, there are many financial solutions in the market,
    but the equity release solutions is said to be standing on a
    solid footing. ” A few years later, in 1908, inspired by the Blackton film (“The Haunting”), was finalized Chomn and finished to the technique of stop-motion in what would be one of his most popular films around the world: ” The
    hotel electricity. To overcome these difficulties
    and to allow businesses to focus on their core business, managed storage services are becoming increasingly popular as a cost effective solutions and a great alternative to traditional storage management.
    Professional call answering services enable offices everywhere
    to take advantage of the latest technology while maintaining a professional image.
    3rd party logistics providers don’t just stock and handle merchandise, they provide crucial support for shippers and retailers who are looking into overseas markets.
    It helps seal in the heating or cooling in homes and there are
    no leakages.

    Also visit my blog post; movers in sarasota florida

  6. Firstly, it is important to check all of your foodstuffs
    for traces of the insect. Whatever you do, do not get her a gift that
    is too forward. The important to making helpful telemarketing scripts is beginning with brief introduction of oneself and the company you are representing.
    You can find companies offering packing services and this means that you have less to worry
    about when moving. I have literally seen a new
    vacuum burnt out after 1 use to clean a small mess like this.
    The word stiletto, stilus in latin, is Italian in nature, and
    it means “any pointed instrument” or “stake”.

    Middle East region is hugely popular among expatriates as a career destination as
    people from all nationalities and religions come together to earn attractive salaries in return for their expert
    services. The nearby public schools have dramatically improved and include dual-language curriculums.
    Simply said, a one way truck is a rental method that allows you to
    rent a truck in a given state and return it at the destination state to a
    branch of the same company in that area. There are more safety precautions you can include in your warehouse storage shelving
    such as shims, wall ties, footplates, extra struts, pallet supports and wire
    decking, and more.

    Visit my weblog moving companies in flint michigan

  7. door raleigh says:

    Nice post. I learn something new and challenging on blogs I
    stumbleupon every day. It’s always interesting to read articles from other authors
    and practice something from their websites.

  8. But wanna comment that you have a very decent site, I love
    the design it actually stands out.

  9. In most homes, a classily designed LCD TV has become an urgent part in every
    entertainment room. The Illinois Movers will give you with an end-to-end
    solution at a cheap basis. The proficient companies of movers and packers in Ghaziabad are always ready
    to offer all essential resettlement services at very reasonable cost.

    For this reason many people make an effort to be brokers of freight companies.
    These kinds of facts ought to be safeguarded continually, all things considered, in the event a competitor happened to acquire these recipes and successfully reproduce
    them, the top firms may go belly up. The Movers are also the right
    choice for expats who are ordered a deputation and will soon be moving this beautiful city
    called Los Angeles. Keep reading this article and get information on various home furnishing items.

    This means that you can just open the door and leave the
    screen closed to enjoy the beautiful weather without pesky bugs.
    The units send to the client are taken back to
    the location where the containers are kept in secured environment.

    Time zones, office locations, will no longer be
    a deciding factor in the claims handling process.

    my web blog rite movers fort lauderdale

  10. Gingko Biloba has been used by the Chinese for centuries
    to treat various ailments and is now thought to be an effective natural treatment for
    tinnitus. Practicing yoga exercises or any other meditation techniques helps
    to a great extend in reducing stress and tension. Biofeedback is a learning process, which trains patients to control certain involuntary movements of
    the body.

    Visit my blog post: what kind of doctor removes hemorrhoids (

  11. tan says:

    Only use those that have a color guide, which will help you
    see where you applied the lotion. Now apply your basic lotion again,
    to the areas mentioned before. This way you can simply wear a light robe to prevent any post tan smearing issues.

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