[SOLVED] command line -P with --<parameter> ?

Three questions about running a script from the command line (I’m using 2.5x):

  1. I’ve seen some reports of problems with script accessing bpy.context when blender is run ‘headless’. What’s up with that? Can I run “with head” from the command line to solve this?

  2. In the docs for command line options, it looks like what I assume must be a script parameter can be included after the script command, like “… -P myscript – <Parameter>”. Can someone give an example command line syntax that passes a script parameter?

  3. How does the script read that parameter mentioned in the above question?

You can invoke blender like that:

./blender -P "/path/to/script.py" -- "params"

Anything after – is not parsed explicitly by blender

Then in your script.py

import sys

args = sys.argv  # this grab all params passed to blender
print(args)  # so you can see what's in there

# if you only need one parameter
your_param = sys.argv[-1] # [-1] grab the last param

excellent! Thank ya kindly