[Bf-blender-cvs] [5bb2044] fracture_modifier: added hack to enable loading fracture presets via python (bpy.context.fracture is not known otherwise when using python_file_run, it needed a fake context

Martin Felke noreply at git.blender.org
Wed Dec 10 23:32:01 CET 2014


Commit: 5bb20444c604d581e6e1cf8cc572c54d32bb6dc9
Author: Martin Felke
Date:   Wed Dec 10 23:30:18 2014 +0100
Branches: fracture_modifier
https://developer.blender.org/rB5bb20444c604d581e6e1cf8cc572c54d32bb6dc9

added hack to enable loading fracture presets via python (bpy.context.fracture is not known otherwise when using python_file_run, it needed a fake context

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

M	release/scripts/startup/bl_operators/presets.py
M	release/scripts/startup/bl_ui/properties_physics_fracture.py

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

diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py
index 7555091..bb068ee 100644
--- a/release/scripts/startup/bl_operators/presets.py
+++ b/release/scripts/startup/bl_operators/presets.py
@@ -207,7 +207,19 @@ class ExecutePreset(Operator):
 
         # execute the preset using script.python_file_run
         if ext == ".py":
-            bpy.ops.script.python_file_run(filepath=filepath)
+            #FRACTURE MODIFIER HACK, cant get bpy.context.fracture to be run via py script else...
+            #so fake a context here
+            mod = False
+            for md in context.object.modifiers:
+                if md.type == 'FRACTURE':
+                    mod = True
+                    break
+            if (mod):
+                ctx = bpy.context.copy()
+                ctx["fracture"] = md
+                bpy.ops.script.python_file_run(ctx, filepath=filepath)
+            else:
+                bpy.ops.script.python_file_run(filepath=filepath)
         elif ext == ".xml":
             import rna_xml
             rna_xml.xml_file_run(context,
@@ -565,6 +577,9 @@ class AddPresetFracture(AddPresetBase, Operator):
         "fracture.breaking_angle_weighted",
         "fracture.breaking_distance",
         "fracture.breaking_distance_weighted",
+        "fracture.cluster_breaking_percentage",
+        "fracture.cluster_breaking_angle",
+        "fracture.cluster_breaking_distance",
         "fracture.solver_iterations_override",
         "fracture.use_mass_dependent_thresholds",
         "fracture.thresh_vertex_group",
@@ -572,7 +587,9 @@ class AddPresetFracture(AddPresetBase, Operator):
         "fracture.inner_vertex_group",
         "fracture.autohide_dist",
         "fracture.fix_normals",
-        "fracture.execute_threaded"
+        "fracture.execute_threaded",
+        "fracture.use_breaking",
+        "fracture.nor_range"
     ]
 
     preset_subdir = "fracture"
diff --git a/release/scripts/startup/bl_ui/properties_physics_fracture.py b/release/scripts/startup/bl_ui/properties_physics_fracture.py
index 5f4cfdf..7fd3316 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fracture.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fracture.py
@@ -22,12 +22,6 @@ from bpy.types import Panel, Menu, UIList
 from bpy.app.translations import pgettext_iface as iface_
 
 
-class FLUID_MT_presets(Menu):
-    bl_label = "Fluid Presets"
-    preset_subdir = "fluid"
-    preset_operator = "script.execute_preset"
-    draw = Menu.draw_preset
-
 class FRACTURE_MT_presets(Menu):
     bl_label = "Fracture Presets"
     preset_subdir = "fracture"




More information about the Bf-blender-cvs mailing list