diff options
-rw-r--r-- | add_mesh_extra_objects/Wallfactory.py | 3 | ||||
-rw-r--r-- | add_mesh_extra_objects/__init__.py | 74 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_beam_builder.py | 3 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_gears.py | 70 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_gemstones.py | 93 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_pipe_joint.py | 15 | ||||
-rw-r--r-- | add_mesh_extra_objects/add_mesh_round_brilliant.py | 34 |
7 files changed, 129 insertions, 163 deletions
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: - bpy.ops.object.vertex_group_remove(all=True) - except: - pass + oldmesh = obj.data + oldmeshname = obj.data.name + + mesh, verts_tip, verts_valley = AddWormGearMesh(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) - 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 = AddWormGearMesh(self, context) - obj = object_utils.object_data_add(context, mesh, operator=None) + bpy.data.meshes.remove(oldmesh) + obj.data.name = oldmeshname else: mesh, verts_tip, verts_valley = AddWormGearMesh(self, context) obj = object_utils.object_data_add(context, mesh, operator=None) diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py index 05d4d137..19e517b9 100644 --- a/add_mesh_extra_objects/add_mesh_gemstones.py +++ b/add_mesh_extra_objects/add_mesh_gemstones.py @@ -273,35 +273,27 @@ class AddDiamond(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 \ + ('Diamond' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object - if 'Diamond' in obj.data.keys(): - oldmesh = obj.data - oldmeshname = obj.data.name - - verts, faces = add_diamond(self.segments, - self.girdle_radius, - self.table_radius, - self.crown_height, - self.pavilion_height) - mesh = bpy.data.meshes.new("TMP") - mesh.from_pydata(verts, [], faces) - mesh.update() - obj.data = mesh - - for material in oldmesh.materials: - obj.data.materials.append(material) - - bpy.data.meshes.remove(oldmesh) - obj.data.name = oldmeshname - else: - verts, faces = add_diamond(self.segments, - self.girdle_radius, - self.table_radius, - self.crown_height, - self.pavilion_height) - - obj = create_mesh_object(context, verts, [], faces, "Diamond") + oldmesh = obj.data + oldmeshname = obj.data.name + + verts, faces = add_diamond(self.segments, + self.girdle_radius, + self.table_radius, + self.crown_height, + self.pavilion_height) + mesh = bpy.data.meshes.new("TMP") + mesh.from_pydata(verts, [], faces) + mesh.update() + obj.data = mesh + + for material in oldmesh.materials: + obj.data.materials.append(material) + + bpy.data.meshes.remove(oldmesh) + obj.data.name = oldmeshname else: verts, faces = add_diamond(self.segments, self.girdle_radius, @@ -413,34 +405,25 @@ class AddGem(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 \ + ('Gem' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object - if 'Gem' in obj.data.keys(): - oldmesh = obj.data - oldmeshname = obj.data.name - verts, faces = add_gem( - self.pavilion_radius, - self.crown_radius, - self.segments, - self.pavilion_height, - self.crown_height) - mesh = bpy.data.meshes.new("TMP") - mesh.from_pydata(verts, [], faces) - mesh.update() - obj.data = mesh - for material in oldmesh.materials: - obj.data.materials.append(material) - bpy.data.meshes.remove(oldmesh) - obj.data.name = oldmeshname - else: - verts, faces = add_gem( - self.pavilion_radius, - self.crown_radius, - self.segments, - self.pavilion_height, - self.crown_height) - - obj = create_mesh_object(context, verts, [], faces, "Gem") + oldmesh = obj.data + oldmeshname = obj.data.name + verts, faces = add_gem( + self.pavilion_radius, + self.crown_radius, + self.segments, + self.pavilion_height, + self.crown_height) + mesh = bpy.data.meshes.new("TMP") + mesh.from_pydata(verts, [], faces) + mesh.update() + obj.data = mesh + for material in oldmesh.materials: + obj.data.materials.append(material) + bpy.data.meshes.remove(oldmesh) + obj.data.name = oldmeshname else: verts, faces = add_gem( self.pavilion_radius, diff --git a/add_mesh_extra_objects/add_mesh_pipe_joint.py b/add_mesh_extra_objects/add_mesh_pipe_joint.py index 85c182bc..99cee55e 100644 --- a/add_mesh_extra_objects/add_mesh_pipe_joint.py +++ b/add_mesh_extra_objects/add_mesh_pipe_joint.py @@ -218,7 +218,8 @@ class AddElbowJoint(Operator): faces.extend(createFaces(loop2, loop3, closed=True)) if bpy.context.mode == "OBJECT": - if self.change == True and self.change != None: + if (context.selected_objects != []) and context.active_object and \ + ('ElbowJoint' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object oldmesh = obj.data oldmeshname = obj.data.name @@ -465,7 +466,8 @@ class AddTeeJoint(Operator): faces.extend(createFaces(loopJoint3, loopMainEnd, closed=True)) if bpy.context.mode == "OBJECT": - if self.change == True and self.change != None: + if (context.selected_objects != []) and context.active_object and \ + ('TeeJoint' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object oldmesh = obj.data oldmeshname = obj.data.name @@ -729,7 +731,8 @@ class AddWyeJoint(Operator): faces.extend(createFaces(loopJoint3, loopArm2, closed=True)) if bpy.context.mode == "OBJECT": - if self.change == True and self.change != None: + if (context.selected_objects != []) and context.active_object and \ + ('WyeJoint' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object oldmesh = obj.data oldmeshname = obj.data.name @@ -1057,7 +1060,8 @@ class AddCrossJoint(Operator): faces.extend(createFaces(loopJoint4, loopArm3, closed=True)) if bpy.context.mode == "OBJECT": - if self.change == True and self.change != None: + if (context.selected_objects != []) and context.active_object and \ + ('CrossJoint' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object oldmesh = obj.data oldmeshname = obj.data.name @@ -1282,7 +1286,8 @@ class AddNJoint(Operator): loopsEndCircles[loopIdx], closed=True)) if bpy.context.mode == "OBJECT": - if self.change == True and self.change != None: + if (context.selected_objects != []) and context.active_object and \ + ('NJoint' 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_round_brilliant.py b/add_mesh_extra_objects/add_mesh_round_brilliant.py index be386770..f68429ee 100644 --- a/add_mesh_extra_objects/add_mesh_round_brilliant.py +++ b/add_mesh_extra_objects/add_mesh_round_brilliant.py @@ -422,27 +422,21 @@ class MESH_OT_primitive_brilliant_add(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 \ + ('Brilliant' in context.active_object.data.keys()) and (self.change == True): obj = context.active_object - if 'Brilliant' in obj.data.keys(): - oldmesh = obj.data - oldmeshname = obj.data.name - mesh = add_mesh_Brilliant(context, self.s, self.table_w, self.crown_h, - self.girdle_t, self.pavi_d, self.bezel_f, - self.pavi_f, self.culet, self.girdle_real, - self.keep_lga, self.g_real_smooth - ) - obj.data = mesh - for material in oldmesh.materials: - obj.data.materials.append(material) - bpy.data.meshes.remove(oldmesh) - obj.data.name = oldmeshname - else: - obj = addBrilliant(context, self.s, self.table_w, self.crown_h, - self.girdle_t, self.pavi_d, self.bezel_f, - self.pavi_f, self.culet, self.girdle_real, - self.keep_lga, self.g_real_smooth - ) + oldmesh = obj.data + oldmeshname = obj.data.name + mesh = add_mesh_Brilliant(context, self.s, self.table_w, self.crown_h, + self.girdle_t, self.pavi_d, self.bezel_f, + self.pavi_f, self.culet, self.girdle_real, + self.keep_lga, self.g_real_smooth + ) + obj.data = mesh + for material in oldmesh.materials: + obj.data.materials.append(material) + bpy.data.meshes.remove(oldmesh) + obj.data.name = oldmeshname else: obj = addBrilliant(context, self.s, self.table_w, self.crown_h, self.girdle_t, self.pavi_d, self.bezel_f, |