background preloader

Python Scripting for Maya Artists

Python Scripting for Maya Artists
This workshop is geared towards students with little to no scripting/programming experience. By the end of this workshop, you will have the knowledge to write and run Python scripts inside and outside of Maya. You will not learn everything about Python from this workshop. This workshop includes all the basic information you should know in order to be proficient in reading, writing, running, and modifying Python scripts. The purpose of this workshop is not to make you expert Python scripters, but to give you a solid foundation from which in further your Python studies. Learning Python, 3rd Edition by Mark Lutz Dive Into Python: The python_inside_maya Google email list: Some Programs that support Python: Maya Modo Houdini XSI Massive Blender Photoshop (indirectly) 3ds max (indirectly) What is Python used for? Artists can Automate repetitive and/or tedious tasks. Engineers can Create applications and tools to run studio pipelines.

Related:  Python + Maya

Python Scripting - Maya Python Download: Available for free download here : Purpose: Spatial Simulation: Andrew F. Scott: Smooth_extrude.mel After the lecture in class on polygonal modeling and its use for tessellating surfaces and creating structural frameworks I decided to go home and do a little MEL scripting for Maya. I revisited a script created by Ming Tang call Super Extrude. It is used to generate a lattice forms from a polygonal model using the extrude commands. I decided to extend the script by unlocking the PolyPoke node and adding the duplicate feature to the script so that you retained a copy of your source geometry. In addition I added a chamfer node as well as PolySmooth node.

Python script 01 – Renamer I’ve been trying to learn scripting languages, Rhinoscript, Processing, MaxScript and etc. After researching and comparing several scripts, I came to the conclusion that Python is the way to go since it is widely adopted by many software, Blender, Houdini, Maya, Realflow and the next version of Rhino. Hopefuly, it will be adopted by Grasshopper soon. This is my first Python script. What this script does is to rename multiple objects at same time, same name with incremetal number, Wooden Trains (Tutorial) 2:14 PM - Dec 26, 2008 Download kit here: (3MB) This is the technical side of the wooden trains work that appears on the artwork page. I wanted to make the trains ride along the tracks and make the track layout fairly flexible.

Ming3D Particle Path Trace Here is ta MEL script you can trace the path of particles and create a curve in Maya. Attached file Food4Rhino For designers who want to use the same flexible language everywhere, GhPython is the Python interpreter component for Grasshopper that allows to execute dynamic scripts of any type. Unlike other scripting components, GhPython allows to use the rhinoscriptsyntax to start scripting without needing to be a programmer. Once on-board and with some practice, you can also get the most of external Python and .Net modules and libraries. This component is open-source, and works in Rhino 5. Join this group to receive updates of new versions, and visit the Grasshopper forum for support. To install:

Lsystems in Python The above information is giving us the outlines of a Python Lturtle class. We'd need a current state list, saved state, and rotation methods. The heading, up and left members of the state tuple are unit vectors. So we need a vector class -- something like this: from coords import Vector class Lturtle: stackstate = [] # remembers saved state delta = 0 # angle of rotation length = 0.5 # full length of turtle move thickness = 0.02 # default thickness of cylinder def __init__(self,vPos=Vector((0,0,0)), vH =Vector((0,0,1)), vL =Vector((0,1,0)), vU =Vector((1,0,0))): """The turtle will start at the origin with the Z-axis as forward direction and Y-axis as left direction. (lparser.txt)""" self.vPos,self.vH,self.vL,self.vU = vPos,vH,vL,vU def turnleft(self): print "Turn Left by delta" def turnright(self): print "Turn Right by delta"

Blobs in Maya – Jose's sketchbook For this post, I have been working on implementing isosurfaces as a modeling tool in Maya to create things such as the one depicted in the image below. Isosurfaces An isosurface is a shape which is described by taking a and building a surface from all the points on the field of which value matches a given threshold level we provide. To generate a polygonal surface we can use in computer graphics, our scalar field will be given by a 3D matrix -or grid- of numbers, which we will iterate in order to fetch the points that describe our shape. Unlike the mathematical scalar field, which is defined in point, our grid describes a sampling of the field, for we only know the values of the field in the vertices of the grid cells.

Python for Grasshopper A new GhPython component brings the Python programming language to Grasshopper in Rhino 5. GhPython introduces Rhinoscript syntax to GrasshopperThe GhPython component is similar to the ones of C# and Vb.Net components in GrasshopperControl the number of inputs and outputs to the componentInclude libraries to the .NET SDK and huge number of Python add-on functionsIntegrates with the new Python editor included in Rhino 5 Python is a modern programming language developed for remarkable power with very clear syntax.

Visualizing L-Systems I previously wrote a little uninspiring post about L-systems and how to generate one in Python. To illustrate their use, I took an existing system from Wikipedia and used that to develop and verify that my visualizations would work correctly. So, here is an image that is done based on the post I made earlier and new code that takes the output of the L-system generator and creates curves to render it our on Maya. Growing organic structures – Jose's sketchbook This project arose from a conversation with my friend Gino , who is currently working on Medical Visualization, about the difficulty for an artist to create growing structures such as veins -let alone animate them- and how to make them look organic, and therefore irregular and adapted to the surrounding they grow upon. The Problem I decided to tackle the problem, and the first approach that came to my mind were L-Systems , which have proven useful for modelling vegetation. There are two restrictions, however, which discouraged me from taking this approach:

Sean Dooley - Scripting Continuingly along the same ideas of the last script of breaking down the creation process of an Lsystem generation, another necessary function is to read in a series of rules. The last script focused on creating the lstring - the string that has the end rules of the Lsystem. But it needs to get its order and creation from somewhere, from something. In this case, these definitions read an external file (sample.dat) and interpret it to something that can later be used to create a Lsystem.