项目作者: bblanimation

项目描述 :
Send taxing Blender operations to the background with subprocess
高级语言: Python
项目地址: git://github.com/bblanimation/background-processing.git
创建时间: 2019-01-07T18:21:33Z
项目社区:https://github.com/bblanimation/background-processing

开源协议:GNU General Public License v3.0

下载


‘Background Processing’:

Run blender processes in the background with separate instances of Blender.

Demo of the Background Processor on YouTube

Instructions for Use:

  • First, add the background processor as a submodule to your addon module
  • Write your own background processing scripts
    • Background processing scripts will be executed from within a separate Blender instance
      • This allows for Blender-only module imports such as bpy and bmesh
      • This also allows for access to the source file’s blend data (if no existing blend data must be accessed, consider setting use_blend_file to False in JobManager.add_job API call for efficiency)
    • Background processing scripts can report their progress with update_job_progress function
      • update_job_progress takes one float argument from 0.0 to 1.0
      • use update_job_progress calls judiciously, as the function has a file write cost
    • Background processing scripts can access the source file’s blend data in two ways
      • Set use_blend_file to True in JobManager.add_job API call (may prove costly for large blend files)
      • Pass blend data directly to the script via the passed_data_blocks parameter of the JobManager.add_job API call
        • Any blend data passed this way will be available as local blend data in the background processing script
        • All blend data passed this way will also be available to the background processing script a passed_data_blocks variable
    • Background processing scripts should include a python_data variable
      • python_data variable should be set to dictionary containing any necessary data to retrieve
      • these data blocks can then be accessed with the JobManager.get_retrieved_python_data API call upon job completion.
    • Background processing scripts should include a data_blocks variable
      • data_blocks variable should be set to list of Blend data blocks
      • The background processor will automatically copy these data blocks to the active instance of Blender upon job completion
      • these data blocks can then be accessed with the JobManager.get_retrieved_data_blocks API call upon job completion.
        • Example use: JobManager.get_retrieved_data_blocks(job).objects
        • NOTE:
          1. dir(JobManager.get_retrieved_data_blocks(job)) = [
          2. 'actions',
          3. 'armatures',
          4. 'brushes',
          5. 'cache_files',
          6. 'cameras',
          7. 'curves',
          8. 'fonts',
          9. 'grease_pencil',
          10. 'groups',
          11. 'images',
          12. 'ipos',
          13. 'lamps',
          14. 'lattices',
          15. 'linestyles',
          16. 'masks',
          17. 'materials',
          18. 'meshes',
          19. 'metaballs',
          20. 'movieclips',
          21. 'node_groups',
          22. 'objects',
          23. 'paint_curves',
          24. 'palettes',
          25. 'particles',
          26. 'scenes',
          27. 'sounds',
          28. 'speakers',
          29. 'texts',
          30. 'textures',
          31. 'worlds',
          32. ]
  • Send scripts to the JobManager for execution
    • Jobs can be added from within a separate operator/code block using the following code:
      1. from .job_manager import * # relative JobManager import path (current path assumes script is in same root folder as 'JobManager.py')
      2. job = "/tmp/test_script.py" # REPLACE with path to your background processing script
      3. job_manager = JobManager.get_instance()
      4. job_manager.add_job(job)
    • You’ll find the entire background processing API in the Job Manager class (classes/job_manager.py)
    • See classes/add_job.py for an example use of the JobManager class API in a custom operator