[Bf-blender-cvs] [af37c3e8f16] master: Cleanup: remove duplicate settings from operator_mesh_add template

Campbell Barton noreply at git.blender.org
Sun Feb 21 09:49:50 CET 2021


Commit: af37c3e8f169b2f519990a24d21ea3251c79711f
Author: Campbell Barton
Date:   Sun Feb 21 19:48:11 2021 +1100
Branches: master
https://developer.blender.org/rBaf37c3e8f169b2f519990a24d21ea3251c79711f

Cleanup: remove duplicate settings from operator_mesh_add template

Also move align items into the enum call as there is no need to have
this accessible from the class.

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

M	release/scripts/modules/bpy_extras/object_utils.py
M	release/scripts/templates_py/operator_mesh_add.py

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

diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index 8d85c19d066..977cbc20f0d 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -172,14 +172,13 @@ class AddObjectHelper:
         if self.align == 'WORLD':
             self.rotation.zero()
 
-    align_items = (
-        ('WORLD', "World", "Align the new object to the world"),
-        ('VIEW', "View", "Align the new object to the view"),
-        ('CURSOR', "3D Cursor", "Use the 3D cursor orientation for the new object")
-    )
     align: EnumProperty(
         name="Align",
-        items=align_items,
+        items=(
+            ('WORLD', "World", "Align the new object to the world"),
+            ('VIEW', "View", "Align the new object to the view"),
+            ('CURSOR', "3D Cursor", "Use the 3D cursor orientation for the new object"),
+        ),
         default='WORLD',
         update=align_update_callback,
     )
diff --git a/release/scripts/templates_py/operator_mesh_add.py b/release/scripts/templates_py/operator_mesh_add.py
index 01a9ad6160e..d0e92888d3b 100644
--- a/release/scripts/templates_py/operator_mesh_add.py
+++ b/release/scripts/templates_py/operator_mesh_add.py
@@ -45,7 +45,7 @@ from bpy.props import (
 )
 
 
-class AddBox(bpy.types.Operator):
+class AddBox(bpy.types.Operator, AddObjectHelper):
     """Add a simple box mesh"""
     bl_idname = "mesh.primitive_box_add"
     bl_label = "Add Box"
@@ -76,27 +76,6 @@ class AddBox(bpy.types.Operator):
         options={'HIDDEN', 'SKIP_SAVE'},
     )
 
-    # generic transform props
-    align_items = (
-        ('WORLD', "World", "Align the new object to the world"),
-        ('VIEW', "View", "Align the new object to the view"),
-        ('CURSOR', "3D Cursor", "Use the 3D cursor orientation for the new object")
-    )
-    align: EnumProperty(
-        name="Align",
-        items=align_items,
-        default='WORLD',
-        update=AddObjectHelper.align_update_callback,
-    )
-    location: FloatVectorProperty(
-        name="Location",
-        subtype='TRANSLATION',
-    )
-    rotation: FloatVectorProperty(
-        name="Rotation",
-        subtype='EULER',
-    )
-
     def execute(self, context):
 
         verts_loc, faces = add_box(



More information about the Bf-blender-cvs mailing list