[Bf-blender-cvs] [f4499084519] soc-2019-npr: LANPR: GP target reset button

YimingWu noreply at git.blender.org
Tue Jul 2 11:49:45 CEST 2019


Commit: f449908451962f50c34963918ca096661f8fcd2c
Author: YimingWu
Date:   Tue Jul 2 17:46:26 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBf449908451962f50c34963918ca096661f8fcd2c

LANPR: GP target reset button

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

M	release/scripts/startup/bl_operators/lanpr.py
M	release/scripts/startup/bl_ui/properties_collection.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py

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

diff --git a/release/scripts/startup/bl_operators/lanpr.py b/release/scripts/startup/bl_operators/lanpr.py
index 0cef8d5e904..64833ea6491 100644
--- a/release/scripts/startup/bl_operators/lanpr.py
+++ b/release/scripts/startup/bl_operators/lanpr.py
@@ -233,10 +233,26 @@ class LANPR_render_composited(bpy.types.Operator):
         
         return {'FINISHED'}
 
+class LANPR_reset_object_transfromations(bpy.types.Operator):
+    """Reset Transformations"""
+    bl_idname = "lanpr.reset_object_transfromations"
+    bl_label = "Reset Transformations"
+
+    obj = bpy.props.StringProperty(name="Target Object")
+    
+    def execute(self, context):
+        print(self.obj)
+        ob = bpy.data.objects[self.obj]
+        ob.location.zero()
+        ob.rotation_euler.zero()
+        ob.scale.xyz=[1,1,1]
+        return {'FINISHED'}
+
 classes=(
     #LANPR_make_composition_scene,
     #LANPR_remove_composition_scene,
     #LANPR_goto_original_scene,
     #LANPR_goto_composition_scene,
     #LANPR_render_composited,
+    LANPR_reset_object_transfromations,
 )
\ No newline at end of file
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index e1446769f0e..d335424321b 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -19,6 +19,7 @@
 # <pep8 compliant>
 from bpy.types import Panel
 from bpy import data
+from mathutils import Vector
 
 
 class CollectionButtonsPanel:
@@ -54,7 +55,13 @@ class COLLECTION_PT_collection_flags(CollectionButtonsPanel, Panel):
         col.prop(collection,"hide_select")
         col.prop(collection,"hide_viewport")
         col.prop(collection,"hide_render")
-            
+
+def is_unit_transformation(ob):
+    if ob.scale.xyz==Vector((1,1,1)) and ob.location.xyz==Vector((0,0,0)) and \
+        ob.rotation_euler.x == 0.0 and ob.rotation_euler.y == 0.0 and ob.rotation_euler.z == 0.0:
+        return True
+    return False
+
 
 class COLLECTION_PT_lanpr_collection(CollectionButtonsPanel, Panel):
     bl_label = "Collection LANPR"
@@ -77,6 +84,12 @@ class COLLECTION_PT_lanpr_collection(CollectionButtonsPanel, Panel):
             
             if lanpr.target:
 
+                if not is_unit_transformation(lanpr.target):
+                    row = layout.row()
+                    row.label(text = "Target GP has self transformations.")
+                    row = layout.row()
+                    row.operator("lanpr.reset_object_transfromations").obj=lanpr.target.name
+
                 row = layout.row(align=True)
                 row.prop(lanpr,'enable_contour',toggle=True)
                 row.prop(lanpr,'enable_crease',toggle=True)
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 68591ac661d..8d2c201aaa4 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -20,7 +20,13 @@
 import bpy
 from bpy.types import Panel
 from bpy.app.translations import pgettext_iface as iface_
+from mathutils import Vector
 
+def is_unit_transformation(ob):
+    if ob.scale.xyz==Vector((1,1,1)) and ob.location.xyz==Vector((0,0,0)) and \
+        ob.rotation_euler.x == 0.0 and ob.rotation_euler.y == 0.0 and ob.rotation_euler.z == 0.0:
+        return True
+    return False
 
 class ModifierButtonsPanel:
     bl_space_type = 'PROPERTIES'
@@ -1697,6 +1703,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         if not md.target:
             layout.label(text="You have to specify a target GP Object")
         else:
+            if not is_unit_transformation(md.target):
+                row = layout.row()
+                row.label(text = "Target GP has self transformations.")
+                row = layout.row()
+                row.operator("lanpr.reset_object_transfromations").obj=md.target.name
             layout.prop(md,'replace', text='Replace existing frames')
             row = layout.row()
             row.prop(md,'layer')



More information about the Bf-blender-cvs mailing list