![maya python ls command maya python ls command](https://i.ytimg.com/vi/13KBklf9ElY/maxresdefault.jpg)
Some other useful resources are, Chad Vernon’s blog on python scripting in Maya. We don't really need to save the Maya file) # Save the file (I have commented this out, since it sometimes causes errors. of Triangles: " + str (polys) + "\n")Ĭmds.file(fileToOpen, force=True, open=True) cmds. cmds.ls( sphere1, apTrue ) List all selected objects named 'group' cmds.ls( group, slTrue ) List all geometry, lights and cameras in the DAG. cmds.ls( sphere1 ) To list all instances of sphere1, use the -ap/allPaths flag. Polys = cmds.polyEvaluate (triangle=True) Note that since sphere1 is instanced, the command below lists only the first instance.
![maya python ls command maya python ls command](https://lasopastate956.weebly.com/uploads/1/2/5/7/125749671/101511887.png)
# proc to get the scene poly/triangle count # Other procedures can be defined here and then called in the main program In cmd line, go to the folder where the script is savedĮg: mayapy scene_stats.py "D:/work/./scenes/billards_table.ma" "C:/./output.txt" Make sure that Path (in env variables) is set to "C:\Program Files\Autodesk\Maya2014\bin" You can add procedures to get a list of all materials and lights in a scene and print that out too.Įxample python script showing how mayapy can be used to run scripts from cmd line, without launching Maya In this example, I have defined a procedure to get the poly/triangle count of a Maya scene and print that into a text file and save it. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Maya python ls command how to#
I have a very simple python script here, which you can use as a skeleton and add your own procedures. The following are 12 code examples for showing how to use ().These examples are extracted from open source projects. In my case, it is this: “C:\Program Files\Autodesk\Maya2014\bin”ģ. Let me create a simple python program that executes a shell command with the os module. Execute Shell command in Python with os module. Since mayapy is in the /bin folder, locate it on your computer and add it’s path to the “Path” environment variable. In this tutorial, I’ll show you a couple of ways you can run shell commands and get its output in your Python program. #continue with your script, using the normalĢ. In your Python script, include the following It is much faster when running Maya in standalone and using /bin/mayapy.exeġ. This is very slow if you launch Maya, open the file and execute the script. I have been developing some tools and scripts where I had to open Maya scenes in batch mode, run a Python script on it and log results in a text file. Recently I discovered the power and flexibility of mayapy interpreter.