simple python examples for 3dsmax

posted in: Blog | 8

So, you’re new to Python or even Maxscript and you think now it’s the time to get your hands dirty and start doing some code right?! Right! Let’s start with the pretty basic stuff.

How to get the selected nodes in 3dsmax and print out their names? How about all scene objects? Easy.

import MaxPlus

def getselectednodenames():
    for node in MaxPlus.SelectionManager.Nodes:
        print node.Name

def getscenenodenames():
    for node in MaxPlus.Core.GetRootNode().Children:
        print node.Name

if __name__ == '__main__':


Pretty easy hein!? Now let’s check how to add a modifier to a selection:

import MaxPlus

def addmodifier(nodes):
    for node in nodes:
        mod = MaxPlus.Factory.CreateObjectModifier(MaxPlus.ClassIds.Noisemodifier)
        for param in  mod.ParameterBlock:
            print param.Name
        mod.ParameterBlock.seed.Value = 12345

if __name__ == '__main__':


Be sure to look at the class definition in for the ClassIds, there you’ll find the name of all the modifiers (along with other classes) you can currently use with python. Also, here we are using the CreateObjectModifier, but if you want to add a WSM modifier you’ll need to use┬áCreateWorldSpaceModifier instead.

Also accessing the parameters is still not that straightforward, hence I’ve included a print out of the ParameterBlock, where all the parameters for the modifiers are stored, to access those parameters, change them, you’ll need to use “modifier.parametername.Value”, take note of the uppercase in Value and that should be it, now you just need to add the modifier to the object with AddModifier().

Hope this gives you a small intro to the new and recent python in 3dsmax!

8 Responses

  1. flo
    | Reply

    def getscenenodenames():
    for node in MaxPlus.Core.GetRootNode().Children:
    print node.Name

    gives you just unlinked objects right? but not all scene objects

  2. Felice DeNigris
    | Reply

    I am trying to start python in 3dsmax 2015, but my knowledge of python is very little and the documentation is poorly written. I am wondering why I type import MaxPlus in 3dsmax listener and nothing happens? But if I type import MaxPlus * it suceeds?! Which way is the most effective way of using python in 3dsmax for a beginner? With Listener? Or a third party editor(which I’m not too fond of) Thanks for your efforts in this blog.

    • Artur Leao
      | Reply

      Hi Felici,
      Thanks for your kind words. I guess the best place to start would be the python developer help. Use the Maxscript listener and go to File and open a new editor window.

      You need to have either a python file and use: python.executefile pathtothefile
      OR you have a string where you write your code in python and then execute it with: python.execute string

      Where pathtofile and string are the path to the python file and the string containing your python code.

      I hope this helps and I can write a blog post for beginners soon, soundes like a good idea ­čÖé

  3. Felice DeNigris
    | Reply

    Thanks so much!! I guess for me I will write lines of code in python and use python.execute string for intro purposes. Thanks alot. An intro tutorial would be awesome!

  4. Felice DeNigris
    | Reply

    Does the SelectionManager class have a ‘Node’ Method? I don’t see such method in the documentation. I see GetNode()

  5. Spencer
    | Reply

    God if only I found this 3 hours ago!!!

  6. Spencer
    | Reply

    What’s the difference between MaxPlus.SelectionManager.GetNodes() and MaxPlus.SelectionManager.Nodes? They both seem to work the same for me.

  7. zhang
    | Reply

    How to change the Unwrap_UVW ‘s parameter of Modifier?? Change Map Channel for 2 ???thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.