0

I have one Maya scene and a Python script where import obj files into it. I need to create a batch render file which calls the maya file and applies the script without opneing maya.

I have this code in a .sh file:

#!/bin/bash
"/Applications/Autodesk/maya2016/Maya.app/Contents/bin/Render" -r file -s 1 -e 4 -cam camera1 -rd "/Users/MyComp/Documents/maya/projects/default/images" "/Users/MyComp/Documents/maya/projects/default/Scenes/test1.mb"

But I have this code into the script which can be an issue or maybe not:

def renderFile(i):
    cmds.setAttr("defaultRenderGlobals.imageFilePrefix", i, type="string")
    cmds.render(batch=True)

If I execute this .sh file it renders without the python script. How can I add the python script?

I need that file for a renderfarm purposes

jpits
  • 41
  • 8
  • 2
    Possible duplicate of [use external python script to open maya and run another script inside maya](http://stackoverflow.com/questions/27437733/use-external-python-script-to-open-maya-and-run-another-script-inside-maya) – Ari Gold Nov 14 '16 at 08:49
  • @AriGold But I don't want to open maya. The rendering process and the script file should be running from the .bat or .sh file. I read that post but I don't know if it is the same I need – jpits Nov 14 '16 at 10:20
  • 1
    exactly, for that you have the maya standalone "mayapy.exe", so maya will run in background without GUI – Ari Gold Nov 14 '16 at 10:36
  • @AriGold I still don't understand if I have to open mayapy.exe or call it from the .bat file and how – jpits Nov 14 '16 at 21:38

1 Answers1

0

I know it's an old thread but thought I'd jump in just incase someone finds this thread in a search.

The comments seem a little confused. This comes from the fact that there are two different Python interpreters being talked about. The first is the system level one, which the original question seems to be talking about. In that case, you can use any of the various shell command launchers (like, subprocess/Popen) that suit your need. Here you are looking to run the render command like you would any other command in in the shell.

In the responses, people there are referring to the other interpreter, the custom Maya Python interpreter (mayapy.exe). In that case you are working with actual Maya libraries and it's the same as working with Python in it's shell, with the added Maya libraries/environment.

The two have different uses, the first is to control things like they were in the shell and the second is controlling things inside of a Maya context. Hope that clarifies things.

renderbox
  • 1,595
  • 14
  • 25