Command line parameter problem
On 19/08/2015 at 06:18, xxxxxxxx wrote:
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:
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
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="
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:
cameraFound = 1
if cameraFound == 1:
camname = adraw.GetSceneCamera(doc).GetName()
print "Camera :", camname, "selected"
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.
On 20/08/2015 at 02:54, xxxxxxxx wrote:
To get the Cinema 4D command line arguments implement PluginMessage() and filter the C4DPL_COMMANDLINEARGS message. In this message sys.argv holds the command line arguments.
You can then store them using a global variable to be used afterwards in your Tag's Execute().
See Command Line Arguments in the Python documentation for a code snippet and more information.
On 20/08/2015 at 14:09, xxxxxxxx wrote:
Thank you very much :) I'm going to try that.