[Bf-extensions-cvs] [6ea26b6f] blender-v2.79-release: archipack: background renderer use factory-startup to prevent other addon issues

Stephen Leger noreply at git.blender.org
Mon Sep 4 15:17:32 CEST 2017


Commit: 6ea26b6fd49fd9f2f8be1c8e98c9159e9be1870d
Author: Stephen Leger
Date:   Fri Sep 1 13:31:09 2017 +0200
Branches: blender-v2.79-release
https://developer.blender.org/rBA6ea26b6fd49fd9f2f8be1c8e98c9159e9be1870d

archipack: background renderer use factory-startup to prevent other addon issues

===================================================================

M	archipack/archipack_rendering.py
M	archipack/archipack_thumbs.py

===================================================================

diff --git a/archipack/archipack_rendering.py b/archipack/archipack_rendering.py
index 4793777e..05373a75 100644
--- a/archipack/archipack_rendering.py
+++ b/archipack/archipack_rendering.py
@@ -48,13 +48,18 @@ class ARCHIPACK_OT_render_thumbs(Operator):
 
     def background_render(self, context, cls, preset):
         generator = path.dirname(path.realpath(__file__)) + path.sep + "archipack_thumbs.py"
+        addon_name = __name__.split('.')[0]
+        matlib_path = context.user_preferences.addons[addon_name].preferences.matlib_path
         # Run external instance of blender like the original thumbnail generator.
         cmd = [
             bpy.app.binary_path,
             "--background",
+            "--factory-startup",
             "-noaudio",
             "--python", generator,
             "--",
+            "addon:" + addon_name,
+            "matlib:" + matlib_path,
             "cls:" + cls,
             "preset:" + preset
             ]
diff --git a/archipack/archipack_thumbs.py b/archipack/archipack_thumbs.py
index c9ab7ad2..8f652ab2 100644
--- a/archipack/archipack_thumbs.py
+++ b/archipack/archipack_thumbs.py
@@ -42,7 +42,10 @@ def generateThumb(context, cls, preset):
     render = context.scene.cycles
     render.progressive = 'PATH'
     render.samples = 24
-    render.use_square_samples = True
+    try:
+        render.use_square_samples = True
+    except:
+        pass
     render.preview_samples = 24
     render.aa_samples = 24
     render.transparent_max_bounces = 8
@@ -179,5 +182,13 @@ if __name__ == "__main__":
             cls = arg[4:]
         if arg.startswith("preset:"):
             preset = arg[7:]
-
+        if arg.startswith("matlib:"):
+            matlib = arg[7:]
+        if arg.startswith("addon:"):
+            module = arg[6:]
+    try:
+        bpy.ops.wm.addon_enable(module=module)
+        bpy.context.user_preferences.addons[module].preferences.matlib_path = matlib
+    except:
+        raise RuntimeError("module name not found")
     generateThumb(bpy.context, cls, preset)



More information about the Bf-extensions-cvs mailing list