3dsmax 2014 Python is out

Extension 1 for 3dsmax 2014 is officially out :

Doc for python :

What do you thing of it ?

As my current employer uses 3ds Max and I’m a Maya guy, seeing Python implemented into the extension was a welcome change!

I installed it last night and poked around a bit. I didn’t come across any new python scripting/editing window, or find a decent way to author/edit/test real chunks of python directly inside Max which has me hunting around slightly scratching head. What’s the expected workflow for developing? Write code externally, then use: python.Execute “import mymodule.py; call_my_method()” in the Maxscript editor/listener? Perhaps executing a file via the Maxscript python call is slightly better, but it still seems disconnected to me based on my limited use.

In Maya, you have direct access to the python interpreter via the script editor, and they even give you a specific python tab in the script editor to separate MEL/Python. I suppose I was expecting a similar implementation. The docs hint at build instructions for Pyside/PyQt, so that’s a plus. I think this is a great first step; perhaps 2015 will piggy back greater ease of use on top of this. I’d personally love to see a roadmap for where this is going.

If you have any workflow tips, please share!

-csa

Same here. Can’t find any built in editor, which sucks. Doesn’t seem like too much work to add a text editor that executes python code.

But at least it’s in and seems to work if you use python.Execute / python.ExecuteFile.

Found in some release notes.

Python Scripting
New support for the popular and easy-to-learn Python® scripting language helps technical directors and developers extend and customize Autodesk® 3ds Max® 2014 software, and more easily integrate it into a Python-based pipeline. Customers can execute Python scripts from MAXScript and the 3ds Max command line; in addition, they can access a subset of the 3ds Max API (application programming interface) from Python scripts, including the ability to evaluate MAXScript code.

Like it’s been mentioned you can run python files by doing the following.
python.executefile “file.py”

There has been some detailed explanation about how to setup remote debugging and execution from the likes of PyCharm and such, within the beta forums by Artur Leao. I’ll see if he’s willing to share here.

Hi guys, I’ve been digging into this since the beta stage so if there’s anything you need just post here and I’ll do my best to help out.

I’ve also wrote some stuff that I will paste here later on, includes setting it up with PyCharm, getting remote debug running and so on. I even wrote a custom class that helps out the process of running .py files directly from PyCharm, you just need to have 3dsmax open.

Thanks to Randall for the heads up on this post!

Later!

And forget about using the Maxscript editor… once you’re in with Pycharm or whatever external IDE you use, you will never want to go back to Maxscript and the Maxscript editor.

Great stuff, thanks for the heads up. I’ll dig about on pyCharm now.

I assumed they would give you a simple ide for executing python code. Guess they want you to work for it :wink:

Thank you for anything you can contribute on that topic. I’d love to be able to use PyCharm once again. Though I gotta say, I’ve been cheating on her with Sublime Text lately :wink:

Artur, nice to see you also on this side :wink: Home we can help.
Having a python editor inside max like maya would be nice for sure. But having one like maxscript editor when we work everydays with pycharm or sublimetext would be a real pain.

Csa3d, I personally use sublimetext2 for my python scripting, and I’m just in total love with it.
Will see if I can connect execution to max, like artur with pycharm. It will be finally better than learning/using another editor if there was one inside max. But integration like in maya or nuke would be awesome for sure.

Let’s see what we can do with pyMax :slight_smile:

I never was such a big fan of integrated editors anyways. As long as you can get remote execution to work i found that to be the better choice. First of all a built in editor is never gonna be as good as dedicated ones i think. And there are quite some annoyances too (like the gui beeing blocked on execution or the editor crashing with max shall you cause a crash…and ooohhh yes i do that :stuck_out_tongue: )

Regards,
Thorsten

Okay, first, all credit for ExternalMaxscriptIDE goes out for Sven Fraeys (http://www.svenfraeys.com) which is the foundation for all the stuff that I did. Having that said, here goes:

  1. Download ExternalMaxscriptIDE : https://dl.dropbox.com/u/1652825/MaxScript/ExternalMaxScriptIDE/ExternalMaxScriptIDE.html

  2. Copy " \ExternalMaxScriptIDE " directory to your local scripts directory “$userScripts”

  3. Run the ExternalMaxScriptIDE_install.ms , this will copy the startup and run ExternalMaxScriptIDE

  4. Install Pycharm - http://www.jetbrains.com/pycharm/download/index.html

  5. Download the MaxPlus.zip here and unzip it to a folder of your choice (ex. C:\Maxplus)

  6. Open Pycharm and open the directory where you unzipped the previous file.

  7. Go to File -> Settings or press Alt+F7 and search for Project Interpreter

  8. Your default project interpreter should be Python 2.7.3 (C:\Python27_64\python.exe) if not, don’t worry go to the next step.

  9. Click Configure interpreters and if you don’t have an interpreter set, click the + button and add your Python interpreter (C:\Python26\python.exe)

  10. With the project interpreter selected on the top list view, click on the Paths tab.

  11. Click the + button and add your default 3dsmax 2014 root folder (C:\Program Files\Autodesk\3ds Max 2014)

  12. Back on the Packages tab, you should see a warning to install “distribute”, click on it and then another for “pip”, install that too. (Optional)

  13. Now click the Install button and search for “nose”, install “nose” package (Description: nose extends unittest to make testing easier/Author:Jason Pellerin) (Optional)

  14. Now search and install “coverage” package. (Optional)

  15. Open 3dsmax 2014

  16. I’ve added a few configurations to run the examples and a “main configuration” that basically runs the main.py file, feel free to create your own files and a new configuration for it.

  17. run.py takes one argument “-f” with the file you want to run

  18. Open main.py and hit Run you should see “hello world” in the maxscript window :slight_smile:

Hope this works out for you, let me know if you find any issues. I’ll make a separate post regarding the remote debugging.

The syntax for run.py is: “python run.py -f c:\path\filenametorun.py”

I’m new to python so please bare with me and my messy code :slight_smile:

Remote debugging (does not work with free version of PyCharm 3.0)

This is adpoted from the Maya tutorial here at the TA forum.

  1. Open Pycharm, open the script you want to debug
  2. Menu Run - Edit Configurations
  3. Add new Python Remote Debug
  4. Name it 3dsMax
  5. Tick Single instance only
  6. Set port to 7720 (or whatever you want)
  7. Untick Redirect output to console and Suspend after connect
  8. Press OK
  9. Select 3dsMax configuration and press the ’Debug’ button

You should see this in the console:

Starting debug server at port 7720
Use the following code to connect to the debugger:
Waiting for connection…
import pydevd
pydevd.settrace(’localhost’, port=7720, suspend=False)

  1. Add this to the script you want to debug, as top level as you can:

import sys

pydev_path = r’C:\Program Files (x86)\JetBrains\PyCharm 2.7.2\helpers’
if not pydev_path in sys.path:
sys.path.append(pydev_path)

from pydev import pydevd
pydevd.settrace(’localhost’, port=7720, suspend=False)

  1. Set your breakpoints in the script in Pycharm

  2. Run the script from 3dsmax with python.Executefile yourpythonscript.py / Optionally you can use the method posted above for running python scripts directly from PyCharm.

  3. Pycharm should popup or blink at the selected breakpoints, business as usual from here on.

  4. Enjoy!


The setup described in the previous post:

Agreed, no question a dedicated ide is going to be nicer. However, it would be nice if Autodesk gave you a way of executing python code [and get decent return values] without leaving the application and do a ton of up front steps. Point in case yesterday, I wanted to evaluate how they implemented python, and now i’m jumping through hoops just to get it to be usable.

Artur, Many thanks for taking the time on this. I’ll be jumping on this today.

No problem, let me know what problems you might find. Regarding editors, I’ve included an example on a python editor I was working on… to run python scripts in max! :smiley: It should be working… It has syntax highlighting, line numbers and so on. Should be doing about the same thing as the maxscript editor by now. Feel free to improve it and post the results!

Great stuff, thanks for sharing Artur!

Thanks for sharing this stuff!

Out of curiousity, has anyone ran across any info about what version of Visual Studio they are building 3ds Max 2014 Ext. against?

think I figured this out…


python.Execute("import platform; print platform.python_compiler()")
MSC v.1500 64 bit (AMD64)

… appears to be 2008. I would have guessed they bumped it up like they did with Maya recently.

-csa

A lot of folks use the maya command port to write code in external editors and execute it inside maya. Might be worth hacking up a similar setup using RPYC

Oh neat! Hadn’t ran across this package yet. I was looking into ZMQ currently, though this might be simpler.
-csa

Thanks Artur, that’s super helpful!