blendersynth.run.run_this_script

Quick utility to run the current script from Blender

class blendersynth.run.run_this_script.ArgumentParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)[source]

Subclass of ArgumentParser to properly handle arguments passed through to Blender.

add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...) None
error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

blendersynth.run.run_this_script.is_blender_running()[source]

Returns True if blender is running, False otherwise

blendersynth.run.run_this_script.is_from_run_this_script()[source]

Returns True if this script is being run from run_this_script

blendersynth.run.run_this_script.run_this_script(*args, open_blender=False, debug=False, IDE='PyCharm', port=5678, host='localhost', blend_src=None, blend_as_copy=False, **kwargs)[source]

Run the script in which this function is called from Blender.

Parameters:
  • open_blender (bool) – If True, open a Blender instance after all code is executed, otherwise run in background

  • debug (bool) – If True, will run in debug mode

  • IDE (str) – IDE to use for debugging. Currently only PyCharm and VSCode are supported

  • port (int) – Port to use for debugging

  • host (str) – Host to use for debugging

  • blend_src (str) – Path to blend file to open (note: this is preferable to blendersynth.load_blend as it handles context better)

  • blend_as_copy (bool) – If True, will copy blend_src to a temp file before opening - this is useful if you want to make sure you don’t accidentally override your blend_src file

args & kwargs are passed to the script being run as command line arguments.

The flag –run_this_script is passed to the script being run to indicate that it is being run from run_this_script. Use function is_from_run_this_script to check if the script is being run from run_this_script.