Skip to content

Instantly share code, notes, and snippets.

@ali1234
Created October 29, 2018 01:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ali1234/c4d08c0e0a36e01c8ad27a8bf6060eaf to your computer and use it in GitHub Desktop.
Save ali1234/c4d08c0e0a36e01c8ad27a8bf6060eaf 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)
@torrinworx
Copy link

This is awesome, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment