On 19/08/2015 at 06:18, xxxxxxxx wrote:
Hi,
We are trying to develop a (Tag) plugin to switch camera's from the command line. We thought we had it working since it works when we open a c4d file in the GUI and it switches to the right camera, but when we render on the render farm (command line / nogui) it doesn't work. It gives us:
File "'CommandLine.pyp'", line 31, in Execute
AttributeError: 'module' object has no attribute 'argv'
In the log
This is the code:
import c4d
import os
import sys
import getopt
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
try:
opts, args = getopt.getopt(sys.argv,"c:s:",["camera=","setting="])
except getopt.GetoptError as err:
print "Error: Unknown command line options!"
print "We only support -c|--camera= -s|--setting="
return False
camera = ''
setting = ''
for opt, arg in opts:
if opt in ("-c", "--camera") :
camera = arg
print "camera = ", camera
elif opt in ("-s", "--setting") :
setting = arg
print "setting = ", setting
commandRead = 1
adraw = doc.GetActiveBaseDraw()
roots = doc.GetObjects()
cameraFound = 0
for obj in roots:
if obj.GetName() == camera:
adraw.SetSceneCamera(obj)
cameraFound = 1
c4d.EventAdd()
if cameraFound == 1:
camname = adraw.GetSceneCamera(doc).GetName()
print "Camera :", camname, "selected"
else:
print "Camera not Found!"
Is getopt not availble during load? Of are we missing something here? I hope someone can help. We need this for a customer job.