Python interpreter in Maya, Houdini, blender, Nuke

What is this?

Python is often used as an extension language for DCC tools and the like. (Other than those listed in the title, Softimage, 3dsMax, Cinema4D, LightWave, modo, 3D-Coat, Motionbuilder, Metasequoia, Vue, etc. Adobe is stubbornly jsx)

These Python environments do not require launching the application itself (GUI) It can be used in interactive mode. I checked with the four listed in the title.

environment

Maya Use ** mayapy.exe ** in the bin of your Maya installation folder.

Example: C:\Program Files\Autodesk\Maya2016\bin\mayapy.exe

Official document: http://help.autodesk.com/view/MAYAUL/2016/JPN/?guid=GUID-83799297-C629-48A8-BCE4-061D3F275215

module

There are currently two types of modules for using Maya features.

--Maya Python (or just cmds)

In many cases, the former is ʻimport maya.cmds as cmds (or ~~ as mc), The latter is used as ʻimport pymel.core as pm (or ~~ as pmc). The latter is an objective wrap of the former (roughly) Originally developed externally, it has been installed as standard equipment since Maya 2011. It is published on github. https://github.com/LumaPictures/pymel

Maya Python maya.cmds can be read, but

import maya.cmds as mc

Even if you look inside, it doesn't feel like it can be used

>>> dir(mc)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']

You can use it by ** initialize **. The following is an example sentence (▼) that was in the document

initialize


try: 			
    import maya.standalone 			
    maya.standalone.initialize() 		
except: 			
    pass

mayapy.png Like.

PyMEL PyMEL can also be read. As soon as you read it, a log similar to the one that appears in the script editor when Maya starts up is printed.

import pymel.core as pm

When I initialized cmds, the memory was about 109MB, but with PyMEL it went about 475MB. About 677MB for normal Maya startup including GUI. mayapy_memory.png

By the way, initialize is also included in the process of reading PyMEL. It is also written in Kojiki. https://github.com/LumaPictures/pymel/blob/master/pymel/internal/startup.py

Houdini Use ** hython.exe ** in your Houdini installation folder.

Example: C:\Program Files\Side Effects Software\Houdini 15.0.244.16\bin\hython.exe

Somehow sys.argv

>>> sys.argv
['C:\\PROGRA~1\\SIDEEF~1\\HOUDIN~1.16\\houdini\\python2.7libs\\houdiniInterpreter.py']

I see.

module

The module for using Houdini's features is the "** hou **" module. It is loaded when hython.exe is started.

>>> dir()
['__builtins__', '__doc__', '__name__', 'hou']

There are various things inside. dir_hou.png

Official document: http://www.sidefx.com/docs/houdini15.0/hom/commandline

If you simply search for "hython", Haskell implementation Python will also appear, so be careful.

numpy In the hython environment, numpy can be loaded by default. Thank you Thank you (

blender Start blender with the option "**-python-console **".

Example: "C:\Program Files\Blender Foundation\Blender\blender.exe" --python-console blender_console.png Above all, it is impressive that the silent blender window pops up (it pops up, but it is a window that I do not use in particular).

Somehow sys.argv

>>> sys.argv
['blender-app.exe', '--python-console']

I see.

module

The module for using the blender function is the "** bpy **" module. Read.

import bpy

contents. It is summarized to some extent.

>>> dir(bpy)
['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'app', 'context', 'data', 'ops', 'path', 'props', 'types', 'utils']

... I haven't used it carefully, so I'm not sure if it's ready for use (laughs) (It seems that the class being read is different from the Python Console on blender (GUI).)

Official document: http://wiki.blender.org/index.php/Doc:JA/2.6/Manual/Render/Command_Line

Python Console : http://www.blender.org/manual/editors/python_console.html Blender Python API : http://www.blender.org/api/blender_python_api_2_76_2/ Scripting & Extending Blender » Introduction : http://www.blender.org/manual/advanced/scripting/introduction.html

numpy Like Houdini, blender can read numpy without doing anything.

End

You will be warned if you have a blender window that doesn't respond behind you, or if you try to close the window loosely. Let's finish it properly with quit () or ʻexit ()`. (... I got an error for a moment at the end, it seems like not found, but well ...)

Nuke Start Nuke with the option "**-t **". t of terminal.

Example: "C:\Program Files\Nuke9.0v8\Nuke9.0.exe" -t

… Then it seems to start as a Python interpreter, The free trial version didn't seem to be licensed and I couldn't try it. nuke_licError.png …。 Rendering from the command line is also restricted, so that's right. is. So, I tried to say it on Nuke as usual.

※ Also, if you give a Python script file after -t, it seems to execute it. "C:\Program Files\Nuke9.0v8\Nuke9.0.exe" -t path\to\your\script.py

module

The module for using Nuke's features is the "** nuke **" module. nuke_script.png Even so, when you just dir (), you already have a lot of things globally. .. ..

Official document: https://www.thefoundry.co.uk/products/nuke/developers/90/pythondevguide/command_line.html

NUKE Python Developer's Guide v9.0v8 documentation : http://docs.thefoundry.co.uk/nuke/90/pythondevguide/index.html

Summary

Houdini, Nuke, the module is loaded from the beginning, Maya, blender can be read arbitrarily, was.

Also, Maya and Houdini have an exe that launches the Python interpreter as it is. Blender and Nuke are patterns that can also be interpreted by adding options.

sys.argv was in Houdini and blender, but Maya and Nuke not mentioned were [''] (empty).

Maya is enthusiastic about Japaneseizing documents around development. Whether it is excellent as a document or whether there is a mistranslation is another frame, but I am grateful.

I would like to see if other Python working tools also have an interactive mode.

bonus

3dsMax The Python API is now included as standard in Max, but it can be used on Max that is started instead of the interactive mode described above. The rest is ** 3dsmaxcmd.exe **. But isn't there an interactive mode? Is there? Basically, it's for batch rendering. I'm sorry I don't understand (laughs)

Executing Python scripts from the command line: http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-Python-API-Documentation/files/GUID-379E0B39-7F56-4764-88B6-B26090948800.htm

ConEmu It is convenient to register conemu.png

ConEmu Project Japanese Top Page --joSdo: https://osdn.jp/projects/conemu/

Recommended Posts

Python interpreter in Maya, Houdini, blender, Nuke
Blender Python API in Houdini (Python 3)
Generate 8 * 8 (64) cubes in Blender Python
Draw Sine Waves in Blender Python
Get started with Python in Blender
Use pathlib in Maya (Python 2.7) for upcoming Python 3.7
Quadtree in Python --2
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Meta-analysis in Python
Unittest in python
Discord in Python
Blender 2.9 Python Extrude extrude
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Use python in Docker container as Pycharm interpreter
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
How to make Python Interpreter changes in Pycharm
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Note assigning image textures to materials in Maya python
[Maya Python] Display .ui created by Qt Designer in Maya
Sorted list in Python
Daily AtCoder # 36 in Python
Clustering text in Python
Daily AtCoder # 2 in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python