Skip to content

Instantly share code, notes, and snippets.

@torrinworx
Forked from ali1234/blender-script.py
Created December 31, 2022 00:20
Show Gist options
  • Select an option

  • Save torrinworx/70165def9bd792f01b355b328cac1c2d to your computer and use it in GitHub Desktop.

Select an option

Save torrinworx/70165def9bd792f01b355b328cac1c2d to your computer and use it in GitHub Desktop.
A Python script which runs itself inside Blender upon being run from the command line. Passes through command line arguments.
#!/usr/bin/env python3
import sys
try:
import bpy
except ImportError:
print('Running myself inside Blender')
import subprocess
exit(subprocess.call(['blender', '--background', '--python', __file__, '--'] + sys.argv))
print('I am running in blender')
argv = sys.argv
argv = argv[argv.index("--") + 1:] # get all args after "--"
print(argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment