This is an update on my YCDIVFX MaxPlus Packages which removes a dependency on ExternalMaxscriptIDE. Now thanks to the brilliant work of Christoph Bülter and his SublimeMax package, we can execute our python scripts in 3ds Max directly from Python without too much hassle, way easier to setup. Don’t be scared with all the bullet points, I’ve tried explain it almost click by click.
I basically deleted code from SublimeMax to make it fit to the simple requirements of run.py and PyCharm.
This should make the setup for PyCharm and 3dsmax much easier, here’s an update on the step-by-step:
- Install PyCharm- http://www.jetbrains.com/pycharm/download/index.html
- Download the YCDIVFX MaxPlus Packages and unzip it to a folder of your choice (ex. C:YCDIVFXMaxPlus)
- Open PyCharm and open the directory where you unzipped the previous file.
- Go to File -> Settings or press Alt+F7 and search for Project Interpreter
- Your default project interpreter should be Python 2.7.3 bundled with 3ds Max (C:/Program Files/Autodesk/3ds Max 2014/python/python.exe) if not, don’t worry go to the next step.
- Click Configure interpreters and if you don’t have an interpreter set, click the + button and add your Python interpreter (C:/Program Files/Autodesk/3ds Max 2014/python/python.exe)
- With the project interpreter selected on the top list view, click on the Paths tab.
- Click the + button and add your default 3dsmax 2014 root folder (C:/Program Files/Autodesk/3ds Max 2014) if it doesn’t show up there already.
- Go to Project Structure and on the right pane, select the “packages” folder and press “Sources” button.
- Press OK
Now let’s setup one configuration and then you can duplicate this one to run other scripts:
- Press Run -> Edit Configurations
- Fill in with the following values – Script: C:YCDIVFXMaxPlusMyExamplesrun.py / Script parameters: -f C:YCDIVFXMaxPlusmain.py
- Press OK
Now open 3dsmax 2014.
In PyCharm just select “run main” and press the Run button (little green play button)
In the 3ds Max Listener you should see this:
hello world
#success
Congratulations, you’ve made it!
You can also run it from the command-line, be sure to check the README file.
Recommended optional installs (distribute, pip, nose and coverage):
- PyCharm settings on the Python Interpreters page, you should see a warning to install “distribute”, click on it and then another for “pip”, install that too.
- Now click the Install button and search for “nose”, install “nose” package (Description: nose extends unittest to make testing easier/Author:Jason Pellerin)
- Now search and install “coverage” package.
If you are interested in remote debugging, check my other blog post here: Pycharm, 3dsmax, remote debugging love!
15 Responses
Creator
Why am I getting “Unresolved attribute reference ‘Cylinder'” when using code from help file?
”’
Demonstrates creating a cylinder and appling a bend modifier.
”’
import MaxPlus
obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
obj.ParameterBlock.Radius.Value = 10.0
obj.ParameterBlock.Height.Value = 30.0
node = MaxPlus.Factory.CreateNode(obj)
mod = MaxPlus.Factory.CreateObjectModifier(MaxPlus.ClassIds.Bend)
mod.ParameterBlock.BendAngle.Value = 45.0
node.AddModifier(mod)
Artur Leao
Try removing the docstring (top 3 lines).
Artur Leao
That works here on my machine. Does the same happen when you run it from inside 3ds Max? Eg. Not using PyCharm.
Creator
Inside 3ds Max in works fine.
python.execute “obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)”
python.execute “node = MaxPlus.Factory.CreateNode(obj)”
Creator
I’m not using them inside PyCharm. I just demonstrate that it is the example code from help file.
I’m using:
import MaxPlus
obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
obj.ParameterBlock.Radius.Value = 10.0
obj.ParameterBlock.Height.Value = 30.0
node = MaxPlus.Factory.CreateNode(obj)
And word “Cylinder” is highlighted with light-brown color. when I hover – Im getting – “Unresolved attribute reference ‘Cylinder’”. When I run –
Traceback (most recent call last):
File “A:/YCDIVFX/MaxPlus/MyExamples/test”, line 2, in
obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Cylinder)
File “C:Program FilesAutodesk3ds Max 2014MaxPlus.py”, line 26429, in CreateGeomObject
return _MaxPlus.Factory_CreateGeomObject(*args)
RuntimeError: Unknown MaxPlus Exception
Process finished with exit code 1
Artur Leao
You can’t run MaxPlus outside of 3dsMax, it needs to run within a 3dsMax instance. So you have two options, save that as a file and inside 3dsMax use the python.ExecuteFile yourfile.py or using the above method described in the post.
Creator
What do you mean by “using the above method described in the post.”? Cause I’m using exactly what described in post =)
Artur Leao
You’ve just said “I’m not using them inside PyCharm.” that is not what I’m describing in the post 🙂 Anyway, you probably don’t have the run configuration properly done.
Check out these steps:
Press Run -> Edit Configurations
Fill in with the following values – Script: C:YCDIVFXMaxPlusMyExamplesrun.py / Script parameters: -f C:YCDIVFXMaxPlusmain.py
Press OK
Also check the image, make sure you have the same settings (with the appropriate paths of course) and then before running, make sure the text next to it says “run main” or in your case “run test” if not, click next to the run button and select the configuration you’ve just created then run that.
Again, you need 3dsMax open when running.
Creator
Ohh. I just type the code inside main.py . run and it’s works! But from custom script didnt work. Script: C:YCDIVFXMaxPlusMyExamplesrun.py each time rewrites to script’s name. Is this the problem? Sorry, i’m new to python.=) But anyway, thanks for the big nad fast help, I can program now!=)
Artur Leao
You’re more than welcome, my pleasure 🙂 Regarding the problem itself, be sure to check the names and the configuration. From what you’ve pasted here:
“A:/YCDIVFX/MaxPlus/MyExamples/test”
I can assume the filename is incorrect, should be something like “A:/YCDIVFX/MaxPlus/MyExamples/test.py”
Take care and happy coding 🙂
Klaudikus
Does this work with remote debugging options? Can I set breakpoints and walk through the code?
Artur Leao
Yeap!
Luke
Thanks, really helpful post all seems to be working well, one slight issue however is an error that says “No module named MaxPlus” not sure if this is meant to happen, if anyone has any advice it would be great to hear.
Artur Leao
Hi Luke, what 3ds Max version are you using?
Jintaek Seo
Great! it works on 3dsMax2015. Really thanks!