Slicer parameters conflicts when adding "--load-file" and "--python-script"

Slicer.exe, “–python-code”, “print(‘Start Slicer from Blender!’)”, “–python-script”, startup_slice_script_file
When adding both “–load-file” and “–python-script”, “–load-file” will not be executed to load .mrb file, and it only executes “–python-script”. Is there a way of adding both parameters and make it working? Thanks.

I don’t think there is any --load-file flag, but i is true that something like

./Slicer --python-code "print('Hello from command-line')" /tmp/scene.mrb

will both load the file (first) and execute the provided python code (second), while

./Slicer --python-script /tmp/script.py /tmp/scene.mrb

won’t load the file /tmp/scene.mrb.

It seems that providing python script explicitly prevents the load of files:

Moving forward

  1. @pieper, @lassoan , is that an inconsistency that should be fixed?

  2. @derekcbr, have you tried to load the scene using your python script? or a combination of python script and python code? e.g.,

./Slicer --python-code "slicer.util.loadScene('/tmp/Scene.mrb')" --python-script /tmp/script.py 
1 Like

@RafaelPalomar - right, this is intentional. The idea is that if you specify a python script then the other command line arguments are made available as sys.argv in python.

1 Like

It would be helpful to describe this in the documentation. I had a look in the Slicer documentation but I did not find specification of command-line arguments for the appplication (only examples in the script repository and some tips in the Python FAQ).

Have I missed something or we should add a new documentation section for describing the frequently used command-line arguments (maybe around here)?

I agree, I don’t think these are documented beyond the brief message you get with --help

Thanks, quite helpful!