[Bf-extensions-cvs] [58321c6f] master: Fix T71025: add_mesh_gears: bpy.ops.object.mode_set.poll() failed

Spivak Vladimir cwolf3d noreply at git.blender.org
Sat Nov 23 14:14:42 CET 2019


Commit: 58321c6ff89f1f0492aeee94064ece7a1983dc51
Author: Spivak Vladimir (cwolf3d)
Date:   Sat Nov 23 15:14:08 2019 +0200
Branches: master
https://developer.blender.org/rBA58321c6ff89f1f0492aeee94064ece7a1983dc51

Fix T71025: add_mesh_gears: bpy.ops.object.mode_set.poll() failed

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

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

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

diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py
index 685b1255..6d74725e 100644
--- a/add_mesh_extra_objects/Wallfactory.py
+++ b/add_mesh_extra_objects/Wallfactory.py
@@ -873,7 +873,8 @@ class add_mesh_wallb(Operator):
                                         )
 
         if bpy.context.mode == "OBJECT":
-            if self.change == True and self.change != None:
+            if context.selected_objects != [] and context.active_object and \
+            ('Wall' in context.active_object.data.keys()) and (self.change == True):
                 obj = context.active_object
                 oldmesh = obj.data
                 oldmeshname = obj.data.name
diff --git a/add_mesh_extra_objects/__init__.py b/add_mesh_extra_objects/__init__.py
index b7a532d4..bef13a58 100644
--- a/add_mesh_extra_objects/__init__.py
+++ b/add_mesh_extra_objects/__init__.py
@@ -20,18 +20,19 @@
 # dreampainter, cotejrp1, liero, Kayo Phoenix, sugiany, dommetysk, Jambay   #
 # Phymec, Anthony D'Agostino, Pablo Vazquez, Richard Wilks, lijenstina,     #
 # Sjaak-de-Draak, Phil Cote, cotejrp1, xyz presets by elfnor, revolt_randy, #
+# Vladimir Spivak (cwolf3d), #
 
 
 bl_info = {
     "name": "Extra Objects",
     "author": "Multiple Authors",
-    "version": (0, 3, 4),
+    "version": (0, 3, 5),
     "blender": (2, 80, 0),
     "location": "View3D > Add > Mesh",
     "description": "Add extra mesh object types",
     "warning": "",
-    "wiki_url": "https://docs.blender.org/manual/en/dev/addons/"
-                "add_mesh/mesh_extra_objects.html",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/"
+                "Py/Scripts/Add_Mesh/Add_Extra",
     "category": "Add Mesh",
 }
 
@@ -114,10 +115,10 @@ class VIEW3D_MT_mesh_gears_add(Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator("mesh.primitive_gear",
-                        text="Gear")
-        layout.operator("mesh.primitive_worm_gear",
-                        text="Worm")
+        oper = layout.operator("mesh.primitive_gear", text="Gear")
+        oper.change = False
+        oper = layout.operator("mesh.primitive_worm_gear", text="Worm")
+        oper.change = False
 
 
 class VIEW3D_MT_mesh_diamonds_add(Menu):
@@ -128,12 +129,12 @@ class VIEW3D_MT_mesh_diamonds_add(Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator("mesh.primitive_brilliant_add",
-                        text="Brilliant Diamond")
-        layout.operator("mesh.primitive_diamond_add",
-                        text="Diamond")
-        layout.operator("mesh.primitive_gem_add",
-                        text="Gem")
+        oper = layout.operator("mesh.primitive_brilliant_add", text="Brilliant Diamond")
+        oper.change = False
+        oper = layout.operator("mesh.primitive_diamond_add", text="Diamond")
+        oper.change = False
+        oper = layout.operator("mesh.primitive_gem_add", text="Gem")
+        oper.change = False
 
 
 class VIEW3D_MT_mesh_math_add(Menu):
@@ -160,21 +161,16 @@ class VIEW3D_MT_mesh_extras_add(Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator("mesh.add_beam",
-                        text="Beam Builder")
-        layout.operator("mesh.wall_add",
-                        text="Wall Factory")
+        oper = layout.operator("mesh.add_beam", text="Beam Builder")
+        oper.change = False
+        oper = layout.operator("mesh.wall_add", text="Wall Factory")
+        oper.change = False
         layout.separator()
-        layout.operator("mesh.primitive_star_add",
-                        text="Simple Star")
-        layout.operator("mesh.primitive_steppyramid_add",
-                        text="Step Pyramid")
-        layout.operator("mesh.honeycomb_add",
-                        text="Honeycomb")
-        layout.operator("mesh.primitive_teapot_add",
-                        text="Teapot+")
-        layout.operator("mesh.menger_sponge_add",
-                        text="Menger Sponge")
+        oper = layout.operator("mesh.primitive_star_add", text="Simple Star")
+        oper = layout.operator("mesh.primitive_steppyramid_add", text="Step Pyramid")
+        oper = layout.operator("mesh.honeycomb_add", text="Honeycomb")
+        oper = layout.operator("mesh.primitive_teapot_add", text="Teapot+")
+        oper = layout.operator("mesh.menger_sponge_add", text="Menger Sponge")
 
 
 class VIEW3D_MT_mesh_torus_add(Menu):
@@ -185,12 +181,9 @@ class VIEW3D_MT_mesh_torus_add(Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator("mesh.primitive_twisted_torus_add",
-                        text="Twisted Torus")
-        layout.operator("mesh.primitive_supertoroid_add",
-                        text="Supertoroid")
-        layout.operator("mesh.primitive_torusknot_add",
-                        text="Torus Knot")
+        layout.operator("mesh.primitive_twisted_torus_add", text="Twisted Torus")
+        layout.operator("mesh.primitive_supertoroid_add", text="Supertoroid")
+        layout.operator("mesh.primitive_torusknot_add", text="Torus Knot")
 
 
 class VIEW3D_MT_mesh_pipe_joints_add(Menu):
@@ -201,16 +194,11 @@ class VIEW3D_MT_mesh_pipe_joints_add(Menu):
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator("mesh.primitive_elbow_joint_add",
-                        text="Pipe Elbow")
-        layout.operator("mesh.primitive_tee_joint_add",
-                        text="Pipe T-Joint")
-        layout.operator("mesh.primitive_wye_joint_add",
-                        text="Pipe Y-Joint")
-        layout.operator("mesh.primitive_cross_joint_add",
-                        text="Pipe Cross-Joint")
-        layout.operator("mesh.primitive_n_joint_add",
-                        text="Pipe N-Joint")
+        layout.operator("mesh.primitive_elbow_joint_add", text="Pipe Elbow")
+        layout.operator("mesh.primitive_tee_joint_add", text="Pipe T-Joint")
+        layout.operator("mesh.primitive_wye_joint_add", text="Pipe Y-Joint")
+        layout.operator("mesh.primitive_cross_joint_add", text="Pipe Cross-Joint")
+        layout.operator("mesh.primitive_n_joint_add", text="Pipe N-Joint")
 
 # Register all operators and panels
 
diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py
index f40e945d..3f62437f 100644
--- a/add_mesh_extra_objects/add_mesh_beam_builder.py
+++ b/add_mesh_extra_objects/add_mesh_beam_builder.py
@@ -760,7 +760,8 @@ class addBeam(Operator):
     def execute(self, context):
         if bpy.context.mode == "OBJECT":
 
-            if self.change == True and self.change != None:
+            if context.selected_objects != [] and context.active_object and \
+            ('Beam' in context.active_object.data.keys()) and (self.change == True):
                 obj = context.active_object
                 oldmesh = obj.data
                 oldmeshname = obj.data.name
diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py
index 55595c95..2bfaf8dc 100644
--- a/add_mesh_extra_objects/add_mesh_gears.py
+++ b/add_mesh_extra_objects/add_mesh_gears.py
@@ -677,26 +677,23 @@ class AddGear(Operator):
     def execute(self, context):
         
         if bpy.context.mode == "OBJECT":
-            if self.change == True and self.change != None:
+            if context.selected_objects != [] and context.active_object and \
+            ('Gear' in context.active_object.data.keys()) and (self.change == True):
                 obj = context.active_object
-                if 'Gear' in obj.data.keys():
-                    oldmesh = obj.data
-                    oldmeshname = obj.data.name
-                    mesh, verts_tip, verts_valley = AddGearMesh(self, context)
-                    obj.data = mesh
-                    try:
-                        bpy.ops.object.vertex_group_remove(all=True)
-                    except:
-                        pass
-                    
-                    for material in oldmesh.materials:
-                        obj.data.materials.append(material)
-                    
-                    bpy.data.meshes.remove(oldmesh)
-                    obj.data.name = oldmeshname
-                else:
-                    mesh, verts_tip, verts_valley = AddGearMesh(self, context)
-                    obj = object_utils.object_data_add(context, mesh, operator=None)
+                oldmesh = obj.data
+                oldmeshname = obj.data.name
+                mesh, verts_tip, verts_valley = AddGearMesh(self, context)
+                obj.data = mesh
+                try:
+                    bpy.ops.object.vertex_group_remove(all=True)
+                except:
+                    pass
+                
+                for material in oldmesh.materials:
+                    obj.data.materials.append(material)
+                
+                bpy.data.meshes.remove(oldmesh)
+                obj.data.name = oldmeshname
             else:
                 mesh, verts_tip, verts_valley = AddGearMesh(self, context)
                 obj = object_utils.object_data_add(context, mesh, operator=None)
@@ -878,27 +875,24 @@ class AddWormGear(Operator):
     def execute(self, context):
 
         if bpy.context.mode == "OBJECT":
-            if self.change == True and self.change != None:
+            if context.selected_objects != [] and context.active_object and \
+            ('WormGear' in context.active_object.data.keys()) and (self.change == True):
                 obj = context.active_object
-                if 'WormGear' in obj.data.keys():
-                    oldmesh = obj.data
-                    oldmeshname = obj.data.name
-
-                    mesh, verts_tip, verts_valley = AddWormGearMesh(self, context)
-                    obj.data = mesh
-                    try:
-         

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list