[Bf-extensions-cvs] [b364669b] master: system_property_chart: support custom properties

Campbell Barton noreply at git.blender.org
Fri Jul 22 08:00:37 CEST 2022


Commit: b364669bd7ec08f1c5c8b9f063f3a421a32a5f7b
Author: Campbell Barton
Date:   Fri Jul 22 15:58:00 2022 +1000
Branches: master
https://developer.blender.org/rBAb364669bd7ec08f1c5c8b9f063f3a421a32a5f7b

system_property_chart: support custom properties

Based on suggestion from D13223, but applied a different fix.

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

M	system_property_chart.py

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

diff --git a/system_property_chart.py b/system_property_chart.py
index b1fa54c2..bb6d4682 100644
--- a/system_property_chart.py
+++ b/system_property_chart.py
@@ -219,16 +219,26 @@ def _property_chart_copy(self, context):
 
     data_path = self.data_path
 
-    # quick & nasty method!
+    data_path_with_dot = data_path
+    if not data_path_with_dot.startswith("["):
+        data_path_with_dot = "." + data_path_with_dot
+
+    code = compile(
+        "obj_iter%s = obj%s" % (data_path_with_dot, data_path_with_dot),
+        "<property_chart>",
+        'exec',
+    )
+
     for obj_iter in selected_objects:
         if obj != obj_iter:
             try:
-                exec("obj_iter.%s = obj.%s" % (data_path, data_path))
+                exec(code, {}, {"obj": obj, "obj_iter": obj_iter})
             except:
                 # just in case we need to know what went wrong!
                 import traceback
                 traceback.print_exc()
 
+
 from bpy.props import StringProperty
 
 
@@ -252,6 +262,7 @@ class CopyPropertyChart(Operator):
 
 # List The Classes #
 
+
 classes = (
     AddPresetProperties,
     SCENE_MT_properties_presets,
@@ -260,6 +271,7 @@ classes = (
     CopyPropertyChart
 )
 
+
 def register():
     for cls in classes:
         bpy.utils.register_class(cls)



More information about the Bf-extensions-cvs mailing list