[Bf-extensions-cvs] [031d22ca] master: Addon Mesh Extra Objects: Added Object Helper

Spivak Vladimir cwolf3d noreply at git.blender.org
Sun Jan 5 01:58:00 CET 2020


Commit: 031d22ca32b164f69457026ff5fb4b686db8a976
Author: Spivak Vladimir (cwolf3d)
Date:   Sun Jan 5 02:57:04 2020 +0200
Branches: master
https://developer.blender.org/rBA031d22ca32b164f69457026ff5fb4b686db8a976

Addon Mesh Extra Objects: Added Object Helper

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

M	add_mesh_extra_objects/Wallfactory.py
M	add_mesh_extra_objects/__init__.py
M	add_mesh_extra_objects/add_mesh_beam_builder.py
M	add_mesh_extra_objects/add_mesh_gears.py
M	add_mesh_extra_objects/add_mesh_gemstones.py
M	add_mesh_extra_objects/add_mesh_pipe_joint.py
M	add_mesh_extra_objects/add_mesh_round_brilliant.py
A	add_mesh_extra_objects/utils.py

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

diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py
index 6d74725e..865f9150 100644
--- a/add_mesh_extra_objects/Wallfactory.py
+++ b/add_mesh_extra_objects/Wallfactory.py
@@ -55,8 +55,9 @@ from .Blocks import (
         stepBack,
         )
 from bpy_extras import object_utils
+from . import utils
 
-class add_mesh_wallb(Operator):
+class add_mesh_wallb(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.wall_add"
     bl_label = "Add a Masonry Wall"
     bl_description = "Create a block (masonry) wall mesh"
@@ -639,6 +640,13 @@ class add_mesh_wallb(Operator):
             row.prop(self, "StepOnly", toggle=True)
             col.prop(self, "StepBack", toggle=True)
 
+        if self.change == False:
+            # generic transform props
+            box = layout.box()
+            box.prop(self, 'align')
+            box.prop(self, 'location')
+            box.prop(self, 'rotation')
+
     # Respond to UI - get the properties set by user.
     # Check and process UI settings to generate masonry
 
@@ -889,6 +897,8 @@ class add_mesh_wallb(Operator):
                 mesh = bpy.data.meshes.new("Wall")
                 mesh.from_pydata(verts_array, [], faces_array)
                 obj = object_utils.object_data_add(context, mesh, operator=None)
+
+                utils.setlocation(self, context)
             
             mesh.update()
             
@@ -910,6 +920,8 @@ class add_mesh_wallb(Operator):
             context.active_object.name = name_active_object
             bpy.ops.object.mode_set(mode='EDIT')
 
+            utils.setlocation(self, context)
+
         return {'FINISHED'}
 
 def WallParameters():
diff --git a/add_mesh_extra_objects/__init__.py b/add_mesh_extra_objects/__init__.py
index ff1d3037..d009f0a5 100644
--- a/add_mesh_extra_objects/__init__.py
+++ b/add_mesh_extra_objects/__init__.py
@@ -26,7 +26,7 @@
 bl_info = {
     "name": "Extra Objects",
     "author": "Multiple Authors",
-    "version": (0, 3, 5),
+    "version": (0, 3, 6),
     "blender": (2, 80, 0),
     "location": "View3D > Add > Mesh",
     "description": "Add extra mesh object types",
diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py
index 3f62437f..4650e37a 100644
--- a/add_mesh_extra_objects/add_mesh_beam_builder.py
+++ b/add_mesh_extra_objects/add_mesh_beam_builder.py
@@ -13,6 +13,7 @@ from bpy.props import (
         StringProperty,
         )
 from bpy_extras import object_utils
+from . import utils
 
 # #####################
 # Create vertices for end of mesh
@@ -675,7 +676,7 @@ def addBeamMesh(sRef, context):
 #
 #  UI functions and object creation.
 
-class addBeam(Operator):
+class addBeam(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.add_beam"
     bl_label = "Beam Builder"
     bl_description = "Create beam meshes of various profiles"
@@ -757,6 +758,13 @@ class addBeam(Operator):
         if self.Type != '0':
             box.prop(self, "edgeA")
 
+        if self.change == False:
+            # generic transform props
+            box = layout.box()
+            box.prop(self, 'align')
+            box.prop(self, 'location')
+            box.prop(self, 'rotation')
+
     def execute(self, context):
         if bpy.context.mode == "OBJECT":
 
@@ -775,6 +783,8 @@ class addBeam(Operator):
                 mesh = addBeamMesh(self, context)
                 obj = object_utils.object_data_add(context, mesh, operator=None)
 
+                utils.setlocation(self, context)
+
             if self.Type == '2':  # Rotate C shape
                 bpy.ops.transform.rotate(value=1.570796, constraint_axis=[False, True, False])
                 bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
@@ -806,10 +816,13 @@ class addBeam(Operator):
             context.active_object.name = name_active_object
             bpy.ops.object.mode_set(mode='EDIT')
 
+            utils.setlocation(self, context)
+
         return {'FINISHED'}
 
 def BeamParameters():
     BeamParameters = [
+            "Type",
             "beamZ",
             "beamX",
             "beamY",
diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py
index 2bfaf8dc..a5fabe4b 100644
--- a/add_mesh_extra_objects/add_mesh_gears.py
+++ b/add_mesh_extra_objects/add_mesh_gears.py
@@ -19,6 +19,7 @@ from mathutils import (
         Matrix,
         )
 from bpy_extras import object_utils
+from . import utils
 
 # A very simple "bridge" tool.
 # Connects two equally long vertex rows with faces.
@@ -562,14 +563,11 @@ def AddGearMesh(self, context):
     return mesh, verts_tip, verts_valley
 
 
-class AddGear(Operator):
+class AddGear(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.primitive_gear"
     bl_label = "Add Gear"
     bl_description = "Construct a gear mesh"
     bl_options = {'REGISTER', 'UNDO', 'PRESET'}
-    
-    # align_matrix for the invoke
-    align_matrix : Matrix()
 
     Gear : BoolProperty(name = "Gear",
                 default = True,
@@ -674,6 +672,17 @@ class AddGear(Operator):
         box.prop(self, 'conangle')
         box.prop(self, 'crown')
 
+        if self.change == False:
+            # generic transform props
+            box = layout.box()
+            box.prop(self, 'align')
+            box.prop(self, 'location')
+            box.prop(self, 'rotation')
+
+    @classmethod
+    def poll(cls, context):
+        return context.scene is not None
+
     def execute(self, context):
         
         if bpy.context.mode == "OBJECT":
@@ -697,7 +706,9 @@ class AddGear(Operator):
             else:
                 mesh, verts_tip, verts_valley = AddGearMesh(self, context)
                 obj = object_utils.object_data_add(context, mesh, operator=None)
-    
+
+                utils.setlocation(self, context)
+
             # Create vertex groups from stored vertices.
             tipGroup = obj.vertex_groups.new(name='Tips')
             tipGroup.add(verts_tip, 1.0, 'ADD')
@@ -729,6 +740,14 @@ class AddGear(Operator):
             bpy.ops.object.join()
             context.active_object.name = name_active_object
             bpy.ops.object.mode_set(mode='EDIT')
+
+            utils.setlocation(self, context)
+
+        return {'FINISHED'}
+
+    def invoke(self, context, event):
+        self.execute(context)
+
         return {'FINISHED'}
 
 def GearParameters():
@@ -766,7 +785,7 @@ def AddWormGearMesh(self, context):
     return mesh, verts_tip, verts_valley
 
 
-class AddWormGear(Operator):
+class AddWormGear(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.primitive_worm_gear"
     bl_label = "Add Worm Gear"
     bl_description = "Construct a worm gear mesh"
@@ -872,6 +891,13 @@ class AddWormGear(Operator):
         box.prop(self, "skew")
         box.prop(self, "crown")
 
+        if self.change == False:
+            # generic transform props
+            box = layout.box()
+            box.prop(self, 'align')
+            box.prop(self, 'location')
+            box.prop(self, 'rotation')
+
     def execute(self, context):
 
         if bpy.context.mode == "OBJECT":
@@ -896,7 +922,9 @@ class AddWormGear(Operator):
             else:
                 mesh, verts_tip, verts_valley = AddWormGearMesh(self, context)
                 obj = object_utils.object_data_add(context, mesh, operator=None)
-    
+
+                utils.setlocation(self, context)
+
             # Create vertex groups from stored vertices.
             tipGroup = obj.vertex_groups.new(name = 'Tips')
             tipGroup.add(verts_tip, 1.0, 'ADD')
@@ -929,6 +957,8 @@ class AddWormGear(Operator):
             context.active_object.name = name_active_object
             bpy.ops.object.mode_set(mode='EDIT')
 
+            utils.setlocation(self, context)
+
         return {'FINISHED'}
 
 def WormGearParameters():
diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py
index 19e517b9..68a7a3f2 100644
--- a/add_mesh_extra_objects/add_mesh_gemstones.py
+++ b/add_mesh_extra_objects/add_mesh_gemstones.py
@@ -13,7 +13,8 @@ from bpy.props import (
         BoolProperty,
         StringProperty,
         )
-
+from bpy_extras import object_utils
+from . import utils
 
 # Create a new mesh (object) from verts/edges/faces.
 # verts/edges/faces ... List of vertices/edges/faces for the
@@ -207,7 +208,7 @@ def add_diamond(segments, girdle_radius, table_radius,
     return verts, faces
 
 
-class AddDiamond(Operator):
+class AddDiamond(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.primitive_diamond_add"
     bl_label = "Add Diamond"
     bl_description = "Construct a diamond mesh"
@@ -270,6 +271,13 @@ class AddDiamond(Operator):
         box.prop(self, "crown_height")
         box.prop(self, "pavilion_height")
 
+        if self.change == False:
+            # generic transform props
+            box = layout.box()
+            box.prop(self, 'align')
+            box.prop(self, 'location')
+            box.prop(self, 'rotation')
+
     def execute(self, context):
         
         if bpy.context.mode == "OBJECT":
@@ -302,7 +310,9 @@ class AddDiamond(Operator):
                     self.pavilion_height)
 
                 obj = create_mesh_object(context, verts, [], faces, "Diamond")
-        
+
+                utils.setlocation(self, context)
+
             obj.data["Diamond"] = True
             obj.data["change"] = False
             for prm in DiamondParameters():
@@ -326,6 +336,8 @@ class AddDiamond(Operator):
             context.active_object.name = name_active_object
             bpy.ops.object.mode_set(mode='EDIT')
 
+            utils.setlocation(self, context)
+
         return {'FINISHED'}
 
 def DiamondParameters():
@@ -339,7 +351,7 @@ def DiamondParameters():
     return DiamondParameters
 
 
-class AddGem(Operator):
+class AddGem(Operator, object_utils.AddObjectHelper):
     bl_idname = "mesh.primitive_gem_add"
     bl_label = "Add Gem"
     bl_description = "Construct an offset faceted gem mesh"
@@ -401,6 +413,13 @@ class AddGem(Operator):
         box.prop(self, "crown_radius")
         box.prop(self, "crown_height

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list