python via pipeline script

16 views
Skip to first unread message

tcomputerchip

unread,
May 24, 2011, 1:11:34 AM5/24/11
to pymel-dev
First, let me say THANK YOU, YOUR A LIFE SAVER!!! It took me a little
bit to get pymel working. I guess the part I did not know about was
mayapy and how to use it. Once I seen your video I felt really dumb.

This is a script I am working on (I stripped out the company/project
stuff). I thought it was a good example for those who are getting
started.

The basic idea is: You have several maya files and you want to bring
them into a new mayafile under a namespace and then save the file as a
new render file.

When you run the file, use: mayapy do_test.py

do_test.py:

from pymel.core import *
import maya.cmds as cmds
import os
import time
_timestamp = time.strftime("%m_%d_%Y_%H_%M_%S")
_session_id = str(os.getpid()) + str(_timestamp)
print "[INFO] session id: %s" % _session_id

project_dir = '/path/to/template' # change this to a real path
# model will come from script
model_file = os.path.join(project_dir, 'sphere.ma') # maya file with a
sphere under a group named MASTER_sphere
light_file = os.path.join(project_dir, 'env_turntable_lowres.ma')
render_file = os.path.join(os.path.split(project_dir)[0], 'render_
%s.ma' % _session_id)
print "[INFO] modeling file: %s" % model_file
print "[INFO] lighting file: %s" % light_file
print "[INFO] render file: %s" % render_file

# new file
cmds.file( f=True, new=True )
cmds.file(light_file, i=True, ns='lightrig')
cmds.file(model_file, i=True, ns='model')
# set playback options
cmds.playbackOptions( animationEndTime=1300, animationStartTime=1001,
minTime=1001, maxTime=1300)
cmds.currentTime(1001)

# save file
cmds.file(rename=render_file)
cmds.file(save=True)

Reply all
Reply to author
Forward
0 new messages