diff --git a/add_curve_extra_objects/__init__.py b/add_curve_extra_objects/__init__.py index e64944fe33bb3ae4da9b29ce55d669a92fe3540a..1e63e8124d69d4d62ec4d8e51d2e3f1f1fa4ba76 100644 --- a/add_curve_extra_objects/__init__.py +++ b/add_curve_extra_objects/__init__.py @@ -276,7 +276,7 @@ def register(): from bpy.utils import register_class for cls in classes: register_class(cls) - + add_curve_simple.register() add_curve_spirals.register() add_curve_aceous_galore.register() @@ -287,7 +287,7 @@ def register(): add_curve_spirofit_bouncespline.register() add_surface_plane_cone.register() beveltaper_curve.register() - + # Add "Extras" menu to the "Add Curve" menu bpy.types.VIEW3D_MT_curve_add.append(menu_func) # Add "Extras" menu to the "Add Surface" menu @@ -299,7 +299,7 @@ def unregister(): bpy.types.VIEW3D_MT_curve_add.remove(menu_func) # Remove "Extras" menu from the "Add Surface" menu. bpy.types.VIEW3D_MT_surface_add.remove(menu_surface) - + add_surface_plane_cone.unregister() add_curve_spirofit_bouncespline.unregister() add_curve_curly.unregister() @@ -310,7 +310,7 @@ def unregister(): add_curve_spirals.unregister() add_curve_simple.unregister() beveltaper_curve.unregister() - + from bpy.utils import unregister_class for cls in reversed(classes): unregister_class(cls) diff --git a/add_curve_extra_objects/add_curve_aceous_galore.py b/add_curve_extra_objects/add_curve_aceous_galore.py index 493b38d155681bbe3e00a65d26bcc8dda3638072..46530d1084041d1caaa594990fd7532bb1c06e19 100644 --- a/add_curve_extra_objects/add_curve_aceous_galore.py +++ b/add_curve_extra_objects/add_curve_aceous_galore.py @@ -744,10 +744,10 @@ def vertsToPoints(Verts, splineType): def createCurve(context, vertArray, self): # output splineType 'POLY' 'NURBS' 'BEZIER' splineType = self.outputType - + # GalloreType as name name = self.ProfileType - + # create object if bpy.context.mode == 'EDIT_CURVE': Curve = context.active_object @@ -756,15 +756,15 @@ def createCurve(context, vertArray, self): # create curve dataCurve = bpy.data.curves.new(name, type='CURVE') # curve data block newSpline = dataCurve.splines.new(type=splineType) # spline - + # create object with newCurve Curve = object_utils.object_data_add(context, dataCurve, operator=self) # place in active scene - + # set newSpline Options newSpline.use_cyclic_u = self.use_cyclic_u newSpline.use_endpoint_u = self.endp_u newSpline.order_u = self.order_u - + # set curve Options Curve.data.dimensions = self.shape Curve.data.use_path = True @@ -782,7 +782,7 @@ def createCurve(context, vertArray, self): else: for point in spline.points: point.select = False - + # create spline from vertarray if splineType == 'BEZIER': newSpline.bezier_points.add(int(len(vertArray) * 0.33)) @@ -799,7 +799,7 @@ def createCurve(context, vertArray, self): newSpline.use_endpoint_u = True for point in newSpline.points: point.select = True - + # move and rotate spline in edit mode if bpy.context.mode == 'EDIT_CURVE': if self.align == "WORLD": @@ -808,7 +808,7 @@ def createCurve(context, vertArray, self): bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z', orient_type='GLOBAL') - + elif self.align == "VIEW": bpy.ops.transform.translate(value = self.location) bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X') @@ -1425,12 +1425,12 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): row = layout.row() row.prop(self, "shape", expand=True) - + # output options col = layout.column() col.label(text="Output Curve Type:") col.row().prop(self, "outputType", expand=True) - + if self.outputType == 'NURBS': col.prop(self, 'order_u') elif self.outputType == 'BEZIER': @@ -1441,7 +1441,7 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): col = layout.column() col.row().prop(self, "edit_mode", expand=True) - + col = layout.column() # AddObjectHelper props col.prop(self, "align") @@ -1456,13 +1456,13 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + # main function main(context, self) - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode @@ -1470,9 +1470,9 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): bpy.ops.object.mode_set(mode = 'EDIT') else: bpy.ops.object.mode_set(mode = 'OBJECT') - + return {'FINISHED'} - + def invoke(self, context, event): # deal with 2D - 3D curve differences if self.ProfileType in ['Helix', 'Cycloid', 'Noise']: @@ -1492,7 +1492,7 @@ class Curveaceous_galore(Operator, object_utils.AddObjectHelper): self.use_cyclic_u = False else: self.use_cyclic_u = True - + self.execute(context) return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_braid.py b/add_curve_extra_objects/add_curve_braid.py index ae250682138f96de6118430221c9ebf4ef7d1638..8041b4bf66a6c4e015165ecce061619f1cb3cbba 100644 --- a/add_curve_extra_objects/add_curve_braid.py +++ b/add_curve_extra_objects/add_curve_braid.py @@ -232,7 +232,7 @@ class Braid(Operator): col.label(text="Geometry Options:") col.prop(self, "strandsize") col.prop(self, "resolution") - + col = layout.column() col.row().prop(self, "edit_mode", expand=True) @@ -240,7 +240,7 @@ class Braid(Operator): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + circle = defaultCircle(self.strandsize) context.scene.collection.objects.link(circle) braid = awesome_braid( @@ -258,10 +258,10 @@ class Braid(Operator): ob.select_set(False) braid.select_set(True) bpy.context.view_layer.objects.active = braid - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode diff --git a/add_curve_extra_objects/add_curve_celtic_links.py b/add_curve_extra_objects/add_curve_celtic_links.py index 87b778fe328372793c72bf225a6d113958f4da40..d3136bdb094c1053cfe431310ab8e25fd5eb4b09 100644 --- a/add_curve_extra_objects/add_curve_celtic_links.py +++ b/add_curve_extra_objects/add_curve_celtic_links.py @@ -125,7 +125,7 @@ class CelticKnotOperator(Operator): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + # Cache some values s = sin(self.crossing_angle) * self.crossing_strength c = cos(self.crossing_angle) * self.crossing_strength @@ -271,9 +271,9 @@ class CelticKnotOperator(Operator): curve_obj.data.bevel_depth = self.geo_bDepth except: pass - + bpy.context.view_layer.objects.active = orig_obj - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode diff --git a/add_curve_extra_objects/add_curve_curly.py b/add_curve_extra_objects/add_curve_curly.py index 65990ee275a715d0b7b75ac31ebaf19940570132..637269b5ba0767ea8ee04479946a9c8ad07e65cc 100644 --- a/add_curve_extra_objects/add_curve_curly.py +++ b/add_curve_extra_objects/add_curve_curly.py @@ -388,7 +388,7 @@ def make_curve(self, context, verts, lh, rh): # create object if bpy.context.mode == 'EDIT_CURVE': Curve = context.active_object - + for spline in Curve.data.splines: if spline.type == 'BEZIER': for point in spline.bezier_points: @@ -417,7 +417,7 @@ def make_curve(self, context, verts, lh, rh): # something weird with this one if types == 1 or types == 2 or types == 3: newSpline.bezier_points[3].handle_left.xyz = lh[p][3] - + else: # create curve dataCurve = bpy.data.curves.new(name='CurlyCurve', type='CURVE') # curvedatablock @@ -438,8 +438,8 @@ def make_curve(self, context, verts, lh, rh): c += 1 # something weird with this one if types == 1 or types == 2 or types == 3: - newSpline.bezier_points[3].handle_left.xyz = lh[p][3] - + newSpline.bezier_points[3].handle_left.xyz = lh[p][3] + # create object with newCurve Curve = object_data_add(context, dataCurve, operator=self) # place in active scene Curve.select_set(True) @@ -451,7 +451,7 @@ def make_curve(self, context, verts, lh, rh): Curve.data.fill_mode = 'FULL' else: Curve.data.fill_mode = 'BOTH' - + # move and rotate spline in edit mode if bpy.context.mode == 'EDIT_CURVE': if self.align == "WORLD": @@ -460,7 +460,7 @@ def make_curve(self, context, verts, lh, rh): bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z', orient_type='GLOBAL') - + elif self.align == "VIEW": bpy.ops.transform.translate(value = self.location) bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X') @@ -508,7 +508,7 @@ class add_curlycurve(Operator, AddObjectHelper): ('3D', "3D", "3D") ] ) - + edit_mode : BoolProperty( name="Show in edit mode", default=True, @@ -526,13 +526,13 @@ class add_curlycurve(Operator, AddObjectHelper): col.label(text = "Resize:") col.prop(self, "scale_x") col.prop(self, "scale_y") - + row = layout.row() row.prop(self, "shape", expand=True) - + col = layout.column(align=True) col.row().prop(self, "edit_mode", expand=True) - + col = layout.column(align=True) # AddObjectHelper props col.prop(self, "align") @@ -543,7 +543,7 @@ class add_curlycurve(Operator, AddObjectHelper): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + if self.types == 1: add_type1(self, context) if self.types == 2: @@ -564,10 +564,10 @@ class add_curlycurve(Operator, AddObjectHelper): add_type9(self, context) if self.types == 10: add_type10(self, context) - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode diff --git a/add_curve_extra_objects/add_curve_simple.py b/add_curve_extra_objects/add_curve_simple.py index 0e92c652c746fa71db0d61e2de0dd01f6733006d..af0555894c461ba0c2c0897553d562f02c4ab5a5 100644 --- a/add_curve_extra_objects/add_curve_simple.py +++ b/add_curve_extra_objects/add_curve_simple.py @@ -408,7 +408,7 @@ def vertsToPoints(Verts, splineType): def main(context, self, use_enter_edit_mode): # output splineType 'POLY' 'NURBS' 'BEZIER' splineType = self.outputType - + sides = abs(int((self.Simple_endangle - self.Simple_startangle) / 90)) # get verts @@ -499,25 +499,25 @@ def main(context, self, use_enter_edit_mode): verts = SimpleTrapezoid( self.Simple_a, self.Simple_b, self.Simple_h, self.Simple_center ) - + # turn verts into array vertArray = vertsToPoints(verts, splineType) - + # create object if bpy.context.mode == 'EDIT_CURVE': - + Curve = context.active_object newSpline = Curve.data.splines.new(type=splineType) # spline else: name = self.Simple_Type # Type as name - + dataCurve = bpy.data.curves.new(name, type='CURVE') # curve data block newSpline = dataCurve.splines.new(type=splineType) # spline # create object with new Curve Curve = object_utils.object_data_add(context, dataCurve, operator=self) # place in active scene Curve.select_set(True) - + for spline in Curve.data.splines: if spline.type == 'BEZIER': for point in spline.bezier_points: @@ -527,7 +527,7 @@ def main(context, self, use_enter_edit_mode): else: for point in spline.points: point.select = False - + # create spline from vertarray all_points = [] if splineType == 'BEZIER': @@ -547,7 +547,7 @@ def main(context, self, use_enter_edit_mode): for point in newSpline.points: all_points.append(point) point.select = True - + n = len(all_points) d = 2 * 0.27606262 @@ -613,7 +613,7 @@ def main(context, self, use_enter_edit_mode): p1.handle_right = v1 p2.handle_left = v2 i += 1 - + if self.Simple_Type == 'Ellipse': all_points[0].handle_right = Vector((self.Simple_a, self.Simple_b * d, 0)) all_points[0].handle_left = Vector((self.Simple_a, -self.Simple_b * d, 0)) @@ -623,7 +623,7 @@ def main(context, self, use_enter_edit_mode): all_points[2].handle_left = Vector((-self.Simple_a, self.Simple_b * d, 0)) all_points[3].handle_right = Vector((self.Simple_a * d, -self.Simple_b, 0)) all_points[3].handle_left = Vector((-self.Simple_a * d, -self.Simple_b, 0)) - + if self.Simple_Type == 'Arc': i = 0 for p1 in all_points: @@ -660,7 +660,7 @@ def main(context, self, use_enter_edit_mode): i += 1 all_points[0].handle_left_type = 'VECTOR' all_points[-1].handle_right_type = 'VECTOR' - + if self.Simple_Type == 'Sector': i = 0 for p1 in all_points: @@ -702,7 +702,7 @@ def main(context, self, use_enter_edit_mode): all_points[0].handle_right_type = 'VECTOR' all_points[1].handle_left_type = 'VECTOR' all_points[-1].handle_right_type = 'VECTOR' - + if self.Simple_Type == 'Segment': i = 0 if self.Simple_a > self.Simple_b: @@ -772,7 +772,7 @@ def main(context, self, use_enter_edit_mode): v2 = Vector((p2.co.x, p2.co.y, 0)) - vh2 p1.handle_right = v1 p2.handle_left = v2 - + i += 1 all_points[0].handle_left_type = 'VECTOR' all_points[n - 1].handle_right_type = 'VECTOR' @@ -783,7 +783,7 @@ def main(context, self, use_enter_edit_mode): newSpline.use_cyclic_u = self.use_cyclic_u newSpline.use_endpoint_u = self.endp_u newSpline.order_u = self.order_u - + # set curve Options Curve.data.dimensions = self.shape Curve.data.use_path = True @@ -791,7 +791,7 @@ def main(context, self, use_enter_edit_mode): Curve.data.fill_mode = 'FULL' else: Curve.data.fill_mode = 'BOTH' - + # move and rotate spline in edit mode if bpy.context.mode == 'EDIT_CURVE': if self.align == "WORLD": @@ -800,7 +800,7 @@ def main(context, self, use_enter_edit_mode): bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[1], orient_axis = 'Y', orient_type='GLOBAL') bpy.ops.transform.rotate(value = self.rotation[2], orient_axis = 'Z', orient_type='GLOBAL') - + elif self.align == "VIEW": bpy.ops.transform.translate(value = self.location) bpy.ops.transform.rotate(value = self.rotation[0], orient_axis = 'X') @@ -875,7 +875,7 @@ def menu(self, context): oper14 = self.layout.operator(Simple.bl_idname, text="Trapezoid", icon="MOD_EDGESPLIT") oper14.Simple_Type = "Trapezoid" oper14.use_cyclic_u = True - + # ------------------------------------------------------------ # Simple operator @@ -1236,12 +1236,12 @@ class Simple(Operator, object_utils.AddObjectHelper): row = layout.row() row.prop(self, "shape", expand=True) - + # output options col = layout.column() col.label(text="Output Curve Type:") col.row().prop(self, "outputType", expand=True) - + if self.outputType == 'NURBS': col.prop(self, "order_u") elif self.outputType == 'BEZIER': @@ -1249,10 +1249,10 @@ class Simple(Operator, object_utils.AddObjectHelper): col = layout.column() col.row().prop(self, "use_cyclic_u", expand=True) - + col = layout.column() col.row().prop(self, "edit_mode", expand=True) - + col = layout.column() # AddObjectHelper props col.prop(self, "align") @@ -1274,29 +1274,29 @@ class Simple(Operator, object_utils.AddObjectHelper): return context.scene is not None def execute(self, context): - + # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + # main function main(context, self, use_enter_edit_mode) - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode - + if self.edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') else: bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} - + def invoke(self, context, event): - + self.execute(context) return {'FINISHED'} diff --git a/add_curve_extra_objects/add_curve_spirals.py b/add_curve_extra_objects/add_curve_spirals.py index e916fbe575ca4b86c4e4137366ab3dad21e9152b..55495ddf1c02cfb4eb33883c3bb0f71f16b104f5 100644 --- a/add_curve_extra_objects/add_curve_spirals.py +++ b/add_curve_extra_objects/add_curve_spirals.py @@ -220,7 +220,7 @@ def vertsToPoints(Verts, splineType): def draw_curve(props, context, align_matrix): # output splineType 'POLY' 'NURBS' 'BEZIER' splineType = props.curve_type - + if props.spiral_type == 'ARCH': verts = make_spiral(props, context) if props.spiral_type == 'LOG': @@ -238,13 +238,13 @@ def draw_curve(props, context, align_matrix): # create curve dataCurve = bpy.data.curves.new(name='Spiral', type='CURVE') # curvedatablock newSpline = dataCurve.splines.new(type=splineType) # spline - + # create object with newCurve Curve = object_data_add(context, dataCurve) # place in active scene Curve.matrix_world = align_matrix # apply matrix Curve.rotation_euler = props.rotation_euler Curve.select_set(True) - + # set curveOptions Curve.data.dimensions = props.shape Curve.data.use_path = True @@ -252,15 +252,15 @@ def draw_curve(props, context, align_matrix): Curve.data.fill_mode = 'FULL' else: Curve.data.fill_mode = 'BOTH' - + # set curveOptions newSpline.use_cyclic_u = props.use_cyclic_u newSpline.use_endpoint_u = props.endp_u newSpline.order_u = props.order_u - + # turn verts into array vertArray = vertsToPoints(verts, splineType) - + for spline in Curve.data.splines: if spline.type == 'BEZIER': for point in spline.bezier_points: @@ -270,7 +270,7 @@ def draw_curve(props, context, align_matrix): else: for point in spline.points: point.select = False - + # create newSpline from vertarray if splineType == 'BEZIER': newSpline.bezier_points.add(int(len(vertArray) * 0.33)) @@ -303,7 +303,7 @@ class CURVE_OT_spirals(Operator): # align_matrix for the invoke align_matrix : Matrix() - + spiral_type : EnumProperty( items=[('ARCH', "Archemedian", "Archemedian"), ("LOG", "Logarithmic", "Logarithmic"), @@ -513,12 +513,12 @@ class CURVE_OT_spirals(Operator): row = layout.row() row.prop(self, "shape", expand=True) - + # output options col = layout.column() col.label(text="Output Curve Type:") col.row().prop(self, "curve_type", expand=True) - + if self.curve_type == 'NURBS': col.prop(self, "order_u") elif self.curve_type == 'BEZIER': @@ -529,7 +529,7 @@ class CURVE_OT_spirals(Operator): col = layout.column() col.row().prop(self, "edit_mode", expand=True) - + box = layout.box() box.label(text="Location:") box.prop(self, "startlocation") @@ -545,17 +545,17 @@ class CURVE_OT_spirals(Operator): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + time_start = time.time() self.align_matrix = align_matrix(context, self.startlocation) draw_curve(self, context, self.align_matrix) - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode - + if self.edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') else: diff --git a/add_curve_extra_objects/add_curve_torus_knots.py b/add_curve_extra_objects/add_curve_torus_knots.py index 952074930eb989eb4ca41976555a80f274df19c3..427aaf4afb0bebcb7b5ba2952000e4b47feb7c37 100644 --- a/add_curve_extra_objects/add_curve_torus_knots.py +++ b/add_curve_extra_objects/add_curve_torus_knots.py @@ -669,7 +669,7 @@ class torus_knot_plus(Operator, AddObjectHelper): box.prop(self, "colorSet") box.prop(self, "random_colors") box.prop(self, "saturation") - + col = layout.column() col.row().prop(self, "edit_mode", expand=True) @@ -689,7 +689,7 @@ class torus_knot_plus(Operator, AddObjectHelper): # turn off 'Enter Edit Mode' use_enter_edit_mode = bpy.context.preferences.edit.use_enter_edit_mode bpy.context.preferences.edit.use_enter_edit_mode = False - + if self.mode == 'EXT_INT': # adjust the equivalent radii pair : (R,r) <=> (eR,iR) self.torus_R = (self.torus_eR + self.torus_iR) * 0.5 @@ -721,10 +721,10 @@ class torus_knot_plus(Operator, AddObjectHelper): # create the curve create_torus_knot(self, context) - + if use_enter_edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') - + # restore pre operator state bpy.context.preferences.edit.use_enter_edit_mode = use_enter_edit_mode diff --git a/add_curve_extra_objects/beveltaper_curve.py b/add_curve_extra_objects/beveltaper_curve.py index d3cc4a9352ff85033d80079ba7f73bd9c7091fa0..6e11ada6a60f595def667e3787cb39cdad91f281 100644 --- a/add_curve_extra_objects/beveltaper_curve.py +++ b/add_curve_extra_objects/beveltaper_curve.py @@ -313,7 +313,7 @@ class add_tapercurve(Operator): col_sub.active = self.link2 row.prop(self, "link2", toggle=True, text="", icon="LINKED") col_sub.prop(self, "diff") - + col = layout.column() col.row().prop(self, "edit_mode", expand=True) @@ -325,7 +325,7 @@ class add_tapercurve(Operator): self.scale_ends2 = self.scale_ends1 = self.scale_mid - self.diff add_taper(self, context) - + if self.edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') else: @@ -410,7 +410,7 @@ class add_bevelcurve(Operator, AddObjectHelper): add_type4(self, context) if self.types == 5: add_type5(self, context) - + if self.edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') else: diff --git a/add_mesh_BoltFactory/Boltfactory.py b/add_mesh_BoltFactory/Boltfactory.py index 26050dfba0e39f8cbd2ada8266a5430b90c15a16..b3d3b1089c4d79643aec7df6008c16fa3a2c4486 100644 --- a/add_mesh_BoltFactory/Boltfactory.py +++ b/add_mesh_BoltFactory/Boltfactory.py @@ -336,7 +336,7 @@ class add_mesh_bolt(Operator, AddObjectHelper): return context.scene is not None def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Bolt' in context.active_object.data.keys()) and (self.change == True): @@ -349,16 +349,16 @@ class add_mesh_bolt(Operator, AddObjectHelper): 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 = createMesh.Create_New_Mesh(self, context) obj = object_utils.object_data_add(context, mesh, operator=self) - + obj.data["Bolt"] = True obj.data["change"] = False for prm in BoltParameters(): @@ -370,7 +370,7 @@ class add_mesh_bolt(Operator, AddObjectHelper): bpy.ops.object.mode_set(mode='OBJECT') mesh = createMesh.Create_New_Mesh(self, context) obj = object_utils.object_data_add(context, mesh, operator=self) - + obj.select_set(True) active_object.select_set(True) bpy.ops.object.join() @@ -387,10 +387,10 @@ class add_mesh_bolt(Operator, AddObjectHelper): # Register: def Bolt_contex_menu(self, context): bl_label = 'Change' - + obj = context.object layout = self.layout - + if 'Bolt' in obj.data.keys(): props = layout.operator("mesh.bolt_add", text="Change Bolt") props.change = True @@ -408,8 +408,8 @@ classes = ( add_mesh_bolt, ) - - + + def register(): for cls in classes: bpy.utils.register_class(cls) diff --git a/add_mesh_BoltFactory/__init__.py b/add_mesh_BoltFactory/__init__.py index 502172048cfdc55cdc6e25b0d396c62fa92539ed..ec9d5dc8d18952037d6a13e7dadd388567026bd5 100644 --- a/add_mesh_BoltFactory/__init__.py +++ b/add_mesh_BoltFactory/__init__.py @@ -46,7 +46,7 @@ import bpy def register(): Boltfactory.register() - + def unregister(): diff --git a/add_mesh_discombobulator/__init__.py b/add_mesh_discombobulator/__init__.py index 24c9e32ac8e0961a8d1eae09c31d65a0dd9aabed..42a368c9c038a33ffb417913de2d0f862d1daf84 100644 --- a/add_mesh_discombobulator/__init__.py +++ b/add_mesh_discombobulator/__init__.py @@ -90,11 +90,11 @@ def register(): def unregister(): # Remove "Extras" menu from the "Add Mesh" menu. bpy.types.VIEW3D_MT_mesh_add.remove(menu_func) - + from bpy.utils import unregister_class for cls in reversed(classes): unregister_class(cls) - + del bpy.types.Scene.discombobulator if __name__ == "__main__": diff --git a/add_mesh_discombobulator/mesh_discombobulator.py b/add_mesh_discombobulator/mesh_discombobulator.py index c2edb67363570d7e0c59d3ab0c7c48ee4a5c8a91..4824ef4b3c1614560d0b49c390f8071bb2d09bad 100644 --- a/add_mesh_discombobulator/mesh_discombobulator.py +++ b/add_mesh_discombobulator/mesh_discombobulator.py @@ -567,7 +567,7 @@ class chooseDoodad(Operator): msg = "Object with this name already saved" DISC_doodads = context.scene.discombobulator.DISC_doodads - + if obj_name not in DISC_doodads: DISC_doodads.append(obj_name) msg = "Saved Doodad object: {}".format(obj_name) @@ -641,7 +641,7 @@ class discombobulator_dodads_list(Menu): def draw(self, context): layout = self.layout - + DISC_doodads = context.scene.discombobulator.DISC_doodads doodle = len(DISC_doodads) @@ -788,7 +788,7 @@ class VIEW3D_OT_tools_discombobulate(Operator): def draw(self, context): layout = self.layout - + self.DISC_doodads = bpy.context.scene.discombobulator.DISC_doodads row = layout.row() diff --git a/add_mesh_extra_objects/Wallfactory.py b/add_mesh_extra_objects/Wallfactory.py index 4aaeae9b6d6df78ffbc675ade81896bec4d1a373..a4e875748d21e0ac9e6564c956d439d06923fb85 100644 --- a/add_mesh_extra_objects/Wallfactory.py +++ b/add_mesh_extra_objects/Wallfactory.py @@ -64,7 +64,7 @@ class add_mesh_wallb(Operator, object_utils.AddObjectHelper): # UI items - API for properties - User accessible variables... # not all options are via UI, and some operations just don't work yet - + Wall : BoolProperty(name = "Wall", default = True, description = "Wall") @@ -896,14 +896,14 @@ class add_mesh_wallb(Operator, object_utils.AddObjectHelper): mesh = bpy.data.meshes.new("Wall") mesh.from_pydata(verts_array, [], faces_array) obj = object_utils.object_data_add(context, mesh, operator=self) - + mesh.update() - + obj.data["Wall"] = True obj.data["change"] = False for prm in WallParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/__init__.py b/add_mesh_extra_objects/__init__.py index b3b2f68284cd1567bdff3a3a867ab12ed0420986..14a0398bc51a42a521ba079c7ad7023da800168f 100644 --- a/add_mesh_extra_objects/__init__.py +++ b/add_mesh_extra_objects/__init__.py @@ -246,10 +246,10 @@ def menu_func(self, context): def Extras_contex_menu(self, context): bl_label = 'Change' - + obj = context.object layout = self.layout - + if 'Gear' in obj.data.keys(): props = layout.operator("mesh.primitive_gear", text="Change Gear") props.change = True @@ -263,7 +263,7 @@ def Extras_contex_menu(self, context): for prm in add_mesh_gears.WormGearParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Beam' in obj.data.keys(): props = layout.operator("mesh.add_beam", text="Change Beam") props.change = True @@ -319,28 +319,28 @@ def Extras_contex_menu(self, context): for prm in add_mesh_gemstones.DiamondParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Gem' in obj.data.keys(): props = layout.operator("mesh.primitive_gem_add", text="Change Gem") props.change = True for prm in add_mesh_gemstones.GemParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Brilliant' in obj.data.keys(): props = layout.operator("mesh.primitive_brilliant_add", text="Change Brilliant") props.change = True for prm in add_mesh_round_brilliant.BrilliantParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Roundcube' in obj.data.keys(): props = layout.operator("mesh.primitive_round_cube_add", text="Change Roundcube") props.change = True for prm in add_mesh_round_cube.RoundCubeParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'TorusKnot' in obj.data.keys(): props = layout.operator("mesh.primitive_torusknot_add", text="Change TorusKnot") props.change = True @@ -361,14 +361,14 @@ def Extras_contex_menu(self, context): for prm in add_mesh_twisted_torus.TwistedTorusParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Star' in obj.data.keys(): props = layout.operator("mesh.primitive_star_add", text="Change Star") props.change = True for prm in add_mesh_star.StarParameters(): setattr(props, prm, obj.data[prm]) layout.separator() - + if 'Pyramid' in obj.data.keys(): props = layout.operator("mesh.primitive_steppyramid_add", text="Change Pyramid") props.change = True @@ -441,7 +441,7 @@ def unregister(): # Remove "Extras" menu from the "Add Mesh" menu and context menu. bpy.types.VIEW3D_MT_object_context_menu.remove(Extras_contex_menu) bpy.types.VIEW3D_MT_mesh_add.remove(menu_func) - + from bpy.utils import unregister_class for cls in reversed(classes): unregister_class(cls) diff --git a/add_mesh_extra_objects/add_mesh_3d_function_surface.py b/add_mesh_extra_objects/add_mesh_3d_function_surface.py index b9842615c3979144c0dfae10106576bc1a70221b..2faae6054b78197a9609948f2ca2779494465230 100644 --- a/add_mesh_extra_objects/add_mesh_3d_function_surface.py +++ b/add_mesh_extra_objects/add_mesh_3d_function_surface.py @@ -536,13 +536,13 @@ class AddXYZFunctionSurface(Operator): return {'CANCELLED'} obj = create_mesh_object(context, verts, [], faces, "XYZ Function") - + if self.show_wire: obj.show_wire = True - + if self.edit_mode: bpy.ops.object.mode_set(mode = 'EDIT') else: - bpy.ops.object.mode_set(mode = 'OBJECT') + bpy.ops.object.mode_set(mode = 'OBJECT') return {'FINISHED'} diff --git a/add_mesh_extra_objects/add_mesh_beam_builder.py b/add_mesh_extra_objects/add_mesh_beam_builder.py index db932baf7269e674a4524d47572082f27d48428a..ceda4ffcf0185aa16534c1b396ca47e69bbe1fdf 100644 --- a/add_mesh_extra_objects/add_mesh_beam_builder.py +++ b/add_mesh_extra_objects/add_mesh_beam_builder.py @@ -687,7 +687,7 @@ class addBeam(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change Beam") - + Type: EnumProperty( items=( ('0', "Box Profile", "Square Beam"), @@ -795,7 +795,7 @@ class addBeam(Operator, object_utils.AddObjectHelper): obj.data[prm] = getattr(self, prm) return {'FINISHED'} - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_gears.py b/add_mesh_extra_objects/add_mesh_gears.py index 0163bee98b7f8730889c18a9e74897252c7416b9..4412833075a61cfde7ea098900be24cc9678dbc1 100644 --- a/add_mesh_extra_objects/add_mesh_gears.py +++ b/add_mesh_extra_objects/add_mesh_gears.py @@ -542,7 +542,7 @@ def add_worm(teethNum, rowNum, radius, Ad, De, p_angle, return verts, faces, vgroup_top, vgroup_valley def AddGearMesh(self, context): - + verts, faces, verts_tip, verts_valley = add_gear( self.number_of_teeth, self.radius, @@ -555,10 +555,10 @@ def AddGearMesh(self, context): conangle=self.conangle, crown=self.crown ) - + mesh = bpy.data.meshes.new("Gear") mesh.from_pydata(verts, [], faces) - + return mesh, verts_tip, verts_valley @@ -683,7 +683,7 @@ class AddGear(Operator, object_utils.AddObjectHelper): return context.scene is not None def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Gear' in context.active_object.data.keys()) and (self.change == True): @@ -696,10 +696,10 @@ class AddGear(Operator, object_utils.AddObjectHelper): 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: @@ -709,10 +709,10 @@ class AddGear(Operator, object_utils.AddObjectHelper): # Create vertex groups from stored vertices. tipGroup = obj.vertex_groups.new(name='Tips') tipGroup.add(verts_tip, 1.0, 'ADD') - + valleyGroup = obj.vertex_groups.new(name='Valleys') valleyGroup.add(verts_valley, 1.0, 'ADD') - + obj.data["Gear"] = True obj.data["change"] = False for prm in GearParameters(): @@ -724,14 +724,14 @@ class AddGear(Operator, object_utils.AddObjectHelper): bpy.ops.object.mode_set(mode='OBJECT') mesh, verts_tip, verts_valley = AddGearMesh(self, context) obj = object_utils.object_data_add(context, mesh, operator=self) - + # Create vertex groups from stored vertices. tipGroup = obj.vertex_groups.new(name='Tips') tipGroup.add(verts_tip, 1.0, 'ADD') - + valleyGroup = obj.vertex_groups.new(name='Valleys') valleyGroup.add(verts_valley, 1.0, 'ADD') - + obj.select_set(True) active_object.select_set(True) bpy.ops.object.join() @@ -773,10 +773,10 @@ def AddWormGearMesh(self, context): skew=self.skew, crown=self.crown ) - + mesh = bpy.data.meshes.new("Worm Gear") mesh.from_pydata(verts, [], faces) - + return mesh, verts_tip, verts_valley @@ -908,10 +908,10 @@ class AddWormGear(Operator, object_utils.AddObjectHelper): 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: @@ -921,10 +921,10 @@ class AddWormGear(Operator, object_utils.AddObjectHelper): # Create vertex groups from stored vertices. tipGroup = obj.vertex_groups.new(name = 'Tips') tipGroup.add(verts_tip, 1.0, 'ADD') - + valleyGroup = obj.vertex_groups.new(name = 'Valleys') valleyGroup.add(verts_valley, 1.0, 'ADD') - + obj.data["WormGear"] = True obj.data["change"] = False for prm in WormGearParameters(): @@ -936,14 +936,14 @@ class AddWormGear(Operator, object_utils.AddObjectHelper): bpy.ops.object.mode_set(mode='OBJECT') mesh, verts_tip, verts_valley = AddWormGearMesh(self, context) obj = object_utils.object_data_add(context, mesh, operator=self) - + # Create vertex groups from stored vertices. tipGroup = obj.vertex_groups.new(name = 'Tips') tipGroup.add(verts_tip, 1.0, 'ADD') - + valleyGroup = obj.vertex_groups.new(name = 'Valleys') valleyGroup.add(verts_valley, 1.0, 'ADD') - + obj.select_set(True) active_object.select_set(True) bpy.ops.object.join() diff --git a/add_mesh_extra_objects/add_mesh_gemstones.py b/add_mesh_extra_objects/add_mesh_gemstones.py index 235a5654f795a94cfd1bbe887b6eacb9d648fd96..5829794b1dc5690e56eafb21e1e6e915a8f560fb 100644 --- a/add_mesh_extra_objects/add_mesh_gemstones.py +++ b/add_mesh_extra_objects/add_mesh_gemstones.py @@ -278,7 +278,7 @@ class AddDiamond(Operator, object_utils.AddObjectHelper): box.prop(self, 'rotation', expand=True) def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Diamond' in context.active_object.data.keys()) and (self.change == True): @@ -295,7 +295,7 @@ class AddDiamond(Operator, object_utils.AddObjectHelper): mesh.from_pydata(verts, [], faces) mesh.update() obj.data = mesh - + for material in oldmesh.materials: obj.data.materials.append(material) @@ -314,7 +314,7 @@ class AddDiamond(Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in DiamondParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name @@ -326,7 +326,7 @@ class AddDiamond(Operator, object_utils.AddObjectHelper): self.pavilion_height) obj = create_mesh_object(context, self, verts, [], faces, "TMP") - + obj.select_set(True) active_object.select_set(True) bpy.ops.object.join() @@ -363,7 +363,7 @@ class AddGem(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change Gem") - + segments: IntProperty( name="Segments", description="Longitudial segmentation", @@ -415,9 +415,9 @@ class AddGem(Operator, object_utils.AddObjectHelper): box.prop(self, 'align', expand=True) box.prop(self, 'location', expand=True) box.prop(self, 'rotation', expand=True) - + def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Gem' in context.active_object.data.keys()) and (self.change == True): @@ -452,7 +452,7 @@ class AddGem(Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in GemParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name @@ -465,7 +465,7 @@ class AddGem(Operator, object_utils.AddObjectHelper): self.crown_height) obj = create_mesh_object(context, self, verts, [], faces, "TMP") - + obj.select_set(True) active_object.select_set(True) bpy.ops.object.join() diff --git a/add_mesh_extra_objects/add_mesh_honeycomb.py b/add_mesh_extra_objects/add_mesh_honeycomb.py index 71fe8833463da87c9ca0dccdd7b147709bb5b2fe..ef7d34db49d32882eca95aec23f7e2bd3d82bd0b 100644 --- a/add_mesh_extra_objects/add_mesh_honeycomb.py +++ b/add_mesh_extra_objects/add_mesh_honeycomb.py @@ -298,7 +298,7 @@ class add_mesh_honeycomb(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in HoneyCombParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_pipe_joint.py b/add_mesh_extra_objects/add_mesh_pipe_joint.py index 0f26561be13ef57e0a90721d8d1fe0926c9a79c8..00902ad513619c0443e2dfed74ed5ec828a71791 100644 --- a/add_mesh_extra_objects/add_mesh_pipe_joint.py +++ b/add_mesh_extra_objects/add_mesh_pipe_joint.py @@ -111,7 +111,7 @@ class AddElbowJoint(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change ElbowJoint") - + radius: FloatProperty( name="Radius", description="The radius of the pipe", @@ -223,7 +223,7 @@ class AddElbowJoint(Operator, object_utils.AddObjectHelper): # Create faces faces.extend(createFaces(loop1, loop2, closed=True)) faces.extend(createFaces(loop2, loop3, closed=True)) - + if bpy.context.mode == "OBJECT": if (context.selected_objects != []) and context.active_object and \ ('ElbowJoint' in context.active_object.data.keys()) and (self.change == True): @@ -289,7 +289,7 @@ class AddTeeJoint(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change TeeJoint") - + radius: FloatProperty( name="Radius", description="The radius of the pipe", @@ -478,7 +478,7 @@ class AddTeeJoint(Operator, object_utils.AddObjectHelper): faces.extend(createFaces(loopMainStart, loopJoint1, closed=True)) faces.extend(createFaces(loopJoint2, loopArm, closed=True)) faces.extend(createFaces(loopJoint3, loopMainEnd, closed=True)) - + if bpy.context.mode == "OBJECT": if (context.selected_objects != []) and context.active_object and \ ('TeeJoint' in context.active_object.data.keys()) and (self.change == True): @@ -542,7 +542,7 @@ class AddWyeJoint(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change WyeJoint") - + radius: FloatProperty( name="Radius", description="The radius of the pipe", @@ -750,7 +750,7 @@ class AddWyeJoint(Operator, object_utils.AddObjectHelper): faces.extend(createFaces(loopMainStart, loopJoint1, closed=True)) faces.extend(createFaces(loopJoint2, loopArm1, closed=True)) faces.extend(createFaces(loopJoint3, loopArm2, closed=True)) - + if bpy.context.mode == "OBJECT": if (context.selected_objects != []) and context.active_object and \ ('WyeJoint' in context.active_object.data.keys()) and (self.change == True): @@ -818,7 +818,7 @@ class AddCrossJoint(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change CrossJoint") - + radius: FloatProperty( name="Radius", description="The radius of the pipe", @@ -1086,7 +1086,7 @@ class AddCrossJoint(Operator, object_utils.AddObjectHelper): faces.extend(createFaces(loopJoint2, loopArm1, closed=True)) faces.extend(createFaces(loopJoint3, loopArm2, closed=True)) faces.extend(createFaces(loopJoint4, loopArm3, closed=True)) - + if bpy.context.mode == "OBJECT": if (context.selected_objects != []) and context.active_object and \ ('CrossJoint' in context.active_object.data.keys()) and (self.change == True): @@ -1149,7 +1149,7 @@ class AddNJoint(Operator, object_utils.AddObjectHelper): change : BoolProperty(name = "Change", default = False, description = "change NJoint") - + radius: FloatProperty( name="Radius", description="The radius of the pipe", @@ -1319,7 +1319,7 @@ class AddNJoint(Operator, object_utils.AddObjectHelper): faces.extend( createFaces(loopsJoints[loopIdx], loopsEndCircles[loopIdx], closed=True)) - + if bpy.context.mode == "OBJECT": if (context.selected_objects != []) and context.active_object and \ ('NJoint' in context.active_object.data.keys()) and (self.change == True): diff --git a/add_mesh_extra_objects/add_mesh_pyramid.py b/add_mesh_extra_objects/add_mesh_pyramid.py index 55685ef5a57c429f2d7ba262496c7f299f740522..cfc086ffba044ff3a99153eb6ad2fb83fea651a1 100644 --- a/add_mesh_extra_objects/add_mesh_pyramid.py +++ b/add_mesh_extra_objects/add_mesh_pyramid.py @@ -96,7 +96,7 @@ def pyramid_mesh(self, context): bm.to_mesh(mesh) mesh.update() - + return mesh @@ -162,7 +162,7 @@ class AddPyramid(bpy.types.Operator, object_utils.AddObjectHelper): col.prop(self, 'rotation', expand=True) def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Pyramid' in context.active_object.data.keys()) and (self.change == True): @@ -182,7 +182,7 @@ class AddPyramid(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in PyramidParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_round_brilliant.py b/add_mesh_extra_objects/add_mesh_round_brilliant.py index 75ffa22eed97221cf9f0b0f12747a609250ef5d4..cd796a53f5ab890323c4c5a34a9cebf632902773 100644 --- a/add_mesh_extra_objects/add_mesh_round_brilliant.py +++ b/add_mesh_extra_objects/add_mesh_round_brilliant.py @@ -224,7 +224,7 @@ def add_mesh_Brilliant(context, s, table_w, crown_h, girdle_t, pavi_d, bezel_f, dmesh = bpy.data.meshes.new("dmesh") dmesh.from_pydata(Verts, [], Faces) dmesh.update() - + return dmesh # object generating function, returns final object @@ -315,7 +315,7 @@ class MESH_OT_primitive_brilliant_add(Operator, object_utils.AddObjectHelper): description = "Brilliant") change : BoolProperty(name = "Change", default = False, - description = "change Brilliant") + description = "change Brilliant") s: IntProperty( name="Segments", @@ -422,7 +422,7 @@ class MESH_OT_primitive_brilliant_add(Operator, object_utils.AddObjectHelper): # call mesh/object generator function with user inputs def execute(self, context): - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Brilliant' in context.active_object.data.keys()) and (self.change == True): @@ -450,7 +450,7 @@ class MESH_OT_primitive_brilliant_add(Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in BrilliantParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_round_cube.py b/add_mesh_extra_objects/add_mesh_round_cube.py index 8aeef160b9e8090d29718e85b08c2a94b8054185..3be67b5bffb9da022511a0dfe98544ed8ca08b77 100644 --- a/add_mesh_extra_objects/add_mesh_round_cube.py +++ b/add_mesh_extra_objects/add_mesh_round_cube.py @@ -398,7 +398,7 @@ class AddRoundCube(Operator, object_utils.AddObjectHelper): self.report({'ERROR'}, 'More than ' + str(self.sanity_check_verts) + ' vertices! Check "No Limit" to proceed') return {'CANCELLED'} - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('Roundcube' in context.active_object.data.keys()) and (self.change == True): @@ -425,7 +425,7 @@ class AddRoundCube(Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in RoundCubeParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_star.py b/add_mesh_extra_objects/add_mesh_star.py index 8346a60644f55f46493d839b53fe1b67c778bce1..105648e32f302997c51f8cc6b49e251ec330ba4e 100644 --- a/add_mesh_extra_objects/add_mesh_star.py +++ b/add_mesh_extra_objects/add_mesh_star.py @@ -236,7 +236,7 @@ class AddStar(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in StarParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_supertoroid.py b/add_mesh_extra_objects/add_mesh_supertoroid.py index 691333af3c70be28052b1e1a45d6f1cf38c66bcf..6aec60b53c41914fcb905d7cbf4c50b82e9c64c0 100644 --- a/add_mesh_extra_objects/add_mesh_supertoroid.py +++ b/add_mesh_extra_objects/add_mesh_supertoroid.py @@ -216,7 +216,7 @@ class add_supertoroid(bpy.types.Operator, object_utils.AddObjectHelper): # at least as big as the radius of the tube if rad2 > rad1: rad1 = rad2 - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('SuperToroid' in context.active_object.data.keys()) and (self.change == True): @@ -253,7 +253,7 @@ class add_supertoroid(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in SuperToroidParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_torusknot.py b/add_mesh_extra_objects/add_mesh_torusknot.py index cf5704337b46d908f4fe2688f39ef6a2d17a4b14..73a0b80f3f489dc4344896373dca4889605ff06e 100644 --- a/add_mesh_extra_objects/add_mesh_torusknot.py +++ b/add_mesh_extra_objects/add_mesh_torusknot.py @@ -122,7 +122,7 @@ class AddTorusKnot(bpy.types.Operator, object_utils.AddObjectHelper): default=1, min=1, max=3 ) - + def draw(self, context): layout = self.layout @@ -162,7 +162,7 @@ class AddTorusKnot(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in TorusKnotParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_extra_objects/add_mesh_twisted_torus.py b/add_mesh_extra_objects/add_mesh_twisted_torus.py index 10a3f72e15264550e2dc0c76ce752aa5046169a5..8bc101698a5eb53fe63ceb686a8b6651b6ba419a 100644 --- a/add_mesh_extra_objects/add_mesh_twisted_torus.py +++ b/add_mesh_extra_objects/add_mesh_twisted_torus.py @@ -230,7 +230,7 @@ class AddTwistedTorus(bpy.types.Operator, object_utils.AddObjectHelper): extra_helper = (self.abso_major_rad - self.abso_minor_rad) * 0.5 self.major_radius = self.abso_minor_rad + extra_helper self.minor_radius = extra_helper - + if bpy.context.mode == "OBJECT": if context.selected_objects != [] and context.active_object and \ ('TwistedTorus' in context.active_object.data.keys()) and (self.change == True): @@ -267,7 +267,7 @@ class AddTwistedTorus(bpy.types.Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in TwistedTorusParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/add_mesh_geodesic_domes/__init__.py b/add_mesh_geodesic_domes/__init__.py index 684c8ff8774e50633f7467079caae4276d57ed13..98820da7903cfc58e93b78b2db9a34b757757efb 100644 --- a/add_mesh_geodesic_domes/__init__.py +++ b/add_mesh_geodesic_domes/__init__.py @@ -15,7 +15,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### -# Contributed to by PKHG, Meta Androcto, Noctumsolis, Lijenstina, +# Contributed to by PKHG, Meta Androcto, Noctumsolis, Lijenstina, # Spivak Vladimir (cwolf3d) # Origunally an addon by Andy Houston @@ -50,7 +50,7 @@ import bpy def Geodesic_contex_menu(self, context): bl_label = 'Change' - + obj = context.object layout = self.layout diff --git a/add_mesh_geodesic_domes/third_domes_panel_271.py b/add_mesh_geodesic_domes/third_domes_panel_271.py index 82734b2a9474d3eaa008fa4f3cd138f6ce29ca1a..f4a9ce548f7f4d137de52c2eb3f8f9fdc46baf2c 100644 --- a/add_mesh_geodesic_domes/third_domes_panel_271.py +++ b/add_mesh_geodesic_domes/third_domes_panel_271.py @@ -41,7 +41,7 @@ class GenerateGeodesicDome(Operator, object_utils.AddObjectHelper): GeodesicDome : BoolProperty(name = "GeodesicDome", default = True, - description = "GeodesicDome") + description = "GeodesicDome") change : BoolProperty(name = "Change", default = False, description = "change Geodesic Dome") @@ -1097,7 +1097,7 @@ class GenerateGeodesicDome(Operator, object_utils.AddObjectHelper): multi_label(help_text, box, text_width) def execute(self, context): - + global last_generated_object, last_imported_mesh, basegeodesic, imported_hubmesh_to_use, error_message # default superformparam = [3, 10, 10, 10, 1, 1, 4, 10, 10, 10, 1, 1, 0, 0, 0.0, 0.0, 0, 0]] superformparam = [self.um, self.un1, self.un2, self.un3, self.ua, @@ -1309,7 +1309,7 @@ class GenerateGeodesicDome(Operator, object_utils.AddObjectHelper): obj.data["change"] = False for prm in GeodesicDomeParameters(): obj.data[prm] = getattr(self, prm) - + if bpy.context.mode == "EDIT_MESH": active_object = context.active_object name_active_object = active_object.name diff --git a/amaranth/modeling/symmetry_tools.py b/amaranth/modeling/symmetry_tools.py index da342abc2f1459c60ef2fe9838fca2a1a85e6f69..d23b4fb9b6f93fc26dbfddbaead61c4b148b2ed4 100644 --- a/amaranth/modeling/symmetry_tools.py +++ b/amaranth/modeling/symmetry_tools.py @@ -181,7 +181,7 @@ def register(): bpy.utils.register_class(AMTH_MESH_OT_find_asymmetric) bpy.utils.register_class(AMTH_MESH_OT_make_symmetric) bpy.types.VIEW3D_MT_edit_mesh.append(ui_symmetry_tools) - + def unregister(): bpy.utils.unregister_class(AMTH_MESH_OT_find_asymmetric) diff --git a/amaranth/render/samples_scene.py b/amaranth/render/samples_scene.py index 87e94c4c35ddc7d7a59789533d6999c4e3f468fa..dbe4daf81927c596bbfc4f176bf889959c7d6c3a 100644 --- a/amaranth/render/samples_scene.py +++ b/amaranth/render/samples_scene.py @@ -149,15 +149,15 @@ def render_cycles_scene_samples(self, context): if list_sampling: #if len(scene.render.layers) == 1 and render.layers[0].samples == 0: - if len(scene.render.views) == 1 and render.view_layers[0].samples == 0: + if len(scene.render.views) == 1 and render.view_layers[0].samples == 0: pass else: col.separator() #col.label(text="RenderLayers:", icon="RENDERLAYERS") - col.label(text="View Layers:", icon="RENDERLAYERS") + col.label(text="View Layers:", icon="RENDERLAYERS") #for rl in scene.render.layers: - for rl in scene.view_layers: + for rl in scene.view_layers: row = col.row(align=True) row.label(text=rl.name, icon="BLANK1") row.prop( @@ -178,7 +178,7 @@ def render_cycles_scene_samples(self, context): cscene = s.cycles #row.label(s.name) - row.label(text=s.name) + row.label(text=s.name) row.prop(cscene, "samples", icon="BLANK1") else: row.label( diff --git a/animation_add_corrective_shape_key.py b/animation_add_corrective_shape_key.py index e0961e8dcbfdef3203046c8e41d9bdf67566a9af..c58e862bbbb9dc2f2678a1c66bcf1ee40df751fc 100644 --- a/animation_add_corrective_shape_key.py +++ b/animation_add_corrective_shape_key.py @@ -41,14 +41,14 @@ object as a new shape key. - Unpose-function reused from a script by Tal Trachtman in 2007 http://www.apexbow.com/randd.html - Converted to Blender 2.5 by Ivo Grigull -- Converted to Blender 2.8 by Tokikake -("fast" option was removed, add new "delta" option +- Converted to Blender 2.8 by Tokikake +("fast" option was removed, add new "delta" option which count currently used shape key values of armature mesh when transfer) Limitations and new delta option for 2.8 - Target mesh may not have any transformation at object level, it will be set to zero. - + - new "delta" option usage, when you hope to make new shape-key with keep currently visible other shape keys value. it can generate new shape key, with value as 1.00. then deform target shape as source shape with keep other shape key values relative. @@ -69,11 +69,11 @@ threshold = 1e-16 def update_mesh(ob): depth = bpy.context.evaluated_depsgraph_get() depth.update() - ob.update_tag() - bpy.context.view_layer.update() + ob.update_tag() + bpy.context.view_layer.update() ob.data.update() - - + + def reset_transform(ob): ob.matrix_local.identity() @@ -124,25 +124,25 @@ def func_add_corrective_pose_shape(source, target, flag): print(ob_1) print(ob_1.active_shape_key) active_key_name = ob_1.active_shape_key.name - + if (flag == True): - # Make mix shape key from currently used shape keys + # Make mix shape key from currently used shape keys if not key_index == 0: ob_1.active_shape_key.value = 0 mix_shape = ob_1.shape_key_add(from_mix = True) mix_shape.name = "Mix_shape" update_mesh(ob_1) - keys = ob_1.data.shape_keys.key_blocks.keys() + keys = ob_1.data.shape_keys.key_blocks.keys() ob_1.active_shape_key_index = keys.index(active_key_name) - - print("active_key_name: ", active_key_name) - + + print("active_key_name: ", active_key_name) + if key_index == 0: new_shapekey = ob_1.shape_key_add() new_shapekey.name = "Shape_" + ob_2.name update_mesh(ob_1) - keys = ob_1.data.shape_keys.key_blocks.keys() - ob_1.active_shape_key_index = keys.index(new_shapekey.name) + keys = ob_1.data.shape_keys.key_blocks.keys() + ob_1.active_shape_key_index = keys.index(new_shapekey.name) # else, the active shape will be used (updated) @@ -196,29 +196,29 @@ def func_add_corrective_pose_shape(source, target, flag): apply_vert_coords(ob_1, mesh_1_key_verts, x) ob_1.show_only_shape_key = True - + if (flag == True): # remove delta of mix-shape key values from new shape key key_index = ob_1.active_shape_key_index - active_key_name = ob_1.active_shape_key.name + active_key_name = ob_1.active_shape_key.name shape_data = ob_1.active_shape_key.data - mix_data = mix_shape.data + mix_data = mix_shape.data for i in range(0, len(mesh_1.vertices)): - shape_data[i].co = mesh_1.vertices[i].co + shape_data[i].co - mix_data[i].co + shape_data[i].co = mesh_1.vertices[i].co + shape_data[i].co - mix_data[i].co update_mesh(ob_1) - + ob_1.active_shape_key_index = ob_1.data.shape_keys.key_blocks.keys().index("Mix_shape") bpy.ops.object.shape_key_remove() ob_1.active_shape_key_index = ob_1.data.shape_keys.key_blocks.keys().index(active_key_name) ob_1.data.update() ob_1.show_only_shape_key = False - + ob_1.active_shape_key.vertex_group = vgroup # set the new shape key value to 1.0, so we see the result instantly ob_1.active_shape_key.value = 1.0 - update_mesh(ob_1) - + update_mesh(ob_1) + class add_corrective_pose_shape(bpy.types.Operator): @@ -244,13 +244,13 @@ class add_corrective_pose_shape(bpy.types.Operator): source = selection[1] else: source = selection[0] - + delta_flag = False func_add_corrective_pose_shape(source, target, delta_flag) return {'FINISHED'} - + class add_corrective_pose_shape_delta (bpy.types.Operator): """Adds first object as shape to second object for the current pose """ \ """while maintaining modifiers and currently used other shape keys""" \ @@ -274,7 +274,7 @@ class add_corrective_pose_shape_delta (bpy.types.Operator): source = selection[1] else: source = selection[0] - + delta_flag = True func_add_corrective_pose_shape(source, target, delta_flag) @@ -431,7 +431,7 @@ def func_add_corrective_pose_shape_fast(source, target): verts = source.data.vertices for n in range(len(verts)): shape_key_verts[n].co = verts[n].co - target.update_tag() + target.update_tag() bpy.context.view_layer.update() # go to all armature modifies and unpose the shape for n in target.modifiers: @@ -446,18 +446,18 @@ def func_add_corrective_pose_shape_fast(source, target): # set the new shape key value to 1.0, so we see the result instantly target.active_shape_key.value = 1.0 - + try: target.active_shape_key.vertex_group = vgroup except: pass target.show_only_shape_key = False - target.update_tag() + target.update_tag() bpy.context.view_layer.update() - + target.data.update() - + @@ -524,6 +524,6 @@ def unregister(): unregister_class(cls) bpy.types.MESH_MT_shape_key_context_menu.remove(vgroups_draw) bpy.types.DATA_PT_modifiers.remove(modifiers_draw) - + if __name__ == "__main__": register() diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py index f26f99ddae467be508abfa17a05387e56ee4f1fe..cf8edb1023e73bf7296ede0e203a04b6ef0adc2d 100644 --- a/blenderkit/autothumb.py +++ b/blenderkit/autothumb.py @@ -280,7 +280,7 @@ class GenerateThumbnailOperator(bpy.types.Operator): bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO') return {'FINISHED'} - + return wm.invoke_props_dialog(self) diff --git a/btrace/bTrace.py b/btrace/bTrace.py index 86961efbc4afc1e2008bf78406d021be23ec9efc..2baae055e132e59f42a9df62acda61776a920e45 100644 --- a/btrace/bTrace.py +++ b/btrace/bTrace.py @@ -240,7 +240,7 @@ class OBJECT_OT_objectconnect(Operator): bpy.ops.curve.btgrow() bpy.data.collections["Btrace"].objects.link(curve) # add to Btrace collection - + # Check if we add grow curve if Btrace.animate: bpy.ops.curve.btgrow() # Add grow curve @@ -312,7 +312,7 @@ class OBJECT_OT_particletrace(Operator): if Btrace.curve_join: tracer = curvetracer('Tracer', 'Splines') - + for x in ps.particles: if not Btrace.curve_join: tracer = curvetracer('Tracer.000', 'Spline.000') @@ -322,7 +322,7 @@ class OBJECT_OT_particletrace(Operator): spline.bezier_points.add((x.lifetime - 1) // particle_step) for t in list(range(int(x.lifetime))): bpy.context.scene.frame_set(t + x.birth_time) - + if not t % particle_step: p = spline.bezier_points[t // particle_step] p.co = x.location @@ -813,7 +813,7 @@ class OBJECT_OT_meshfollow(Operator): if curveobject.type == 'CURVE': curveobject.select_set(True) bpy.context.view_layer.objects.active = curveobject - + bpy.data.collections["Btrace"].objects.link(curveobject) #2.8 link obj to collection bpy.context.scene.collection.objects.unlink(curveobject) # unlink from scene collection # bpy.ops.object.group_link(group="Btrace") @@ -852,7 +852,7 @@ def addtracemat(matobj): matslots = bpy.context.object.data.materials.items() if len(matslots) < 1: # Make sure there is only one material slot - + Btrace = bpy.context.window_manager.curve_tracer # Check if color blender is to be run @@ -909,14 +909,14 @@ def addtracemat(matobj): mat_color = Btrace.trace_mat_color TraceMat = bpy.data.materials.new('TraceMat') - - TraceMat.use_nodes = True + + TraceMat.use_nodes = True BSDF = TraceMat.node_tree.nodes[1] r, g, b = mat_color[0], mat_color[1], mat_color[2] BSDF.inputs[0].default_value = [r, g, b, 1] # change node color TraceMat.diffuse_color = [r, g, b, 1] # change viewport color - - + + # Add material to object matobj.materials.append(bpy.data.materials.get(TraceMat.name)) diff --git a/curve_assign_shapekey.py b/curve_assign_shapekey.py index f9d8b50107e6a87e8fea83b03be07e063b82335e..1ca8d10ac9ab0257d8579ae724daaf2838a25e58 100644 --- a/curve_assign_shapekey.py +++ b/curve_assign_shapekey.py @@ -1057,7 +1057,7 @@ class AssignShapeKeysPanel(Panel): def draw(self, context): layout = self.layout - layout.label(text='Morph Curves:') + layout.label(text='Morph Curves:') col = layout.column() params = context.window_manager.AssignShapeKeyParams diff --git a/curve_simplify.py b/curve_simplify.py index 2f31d3e4643e5fba58952e9f4dff9cd86b752acd..2817aef26aeb687b24b023e6a7ff6c1ea812c137 100644 --- a/curve_simplify.py +++ b/curve_simplify.py @@ -596,66 +596,66 @@ def main_rd(context, distance = 0.01): selected_Curves = context.selected_objects if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='EDIT') - + for curve in selected_Curves: bezier_dellist = [] dellist = [] - - for spline in curve.data.splines: + + for spline in curve.data.splines: if spline.type == 'BEZIER': if len(spline.bezier_points) > 1: - for i in range(0, len(spline.bezier_points)): - + for i in range(0, len(spline.bezier_points)): + if i == 0: ii = len(spline.bezier_points) - 1 - else: + else: ii = i - 1 - + dot = spline.bezier_points[i]; - dot1 = spline.bezier_points[ii]; - + dot1 = spline.bezier_points[ii]; + while dot1 in bezier_dellist and i != ii: ii -= 1 - if ii < 0: + if ii < 0: ii = len(spline.bezier_points)-1 dot1 = spline.bezier_points[ii] - - if dot.select_control_point and dot1.select_control_point and (i!=0 or spline.use_cyclic_u): - + + if dot.select_control_point and dot1.select_control_point and (i!=0 or spline.use_cyclic_u): + if (dot.co-dot1.co).length < distance: # remove points and recreate hangles dot1.handle_right_type = "FREE" dot1.handle_right = dot.handle_right dot1.co = (dot.co + dot1.co) / 2 bezier_dellist.append(dot) - + else: # Handles that are on main point position converts to vector, # if next handle are also vector if dot.handle_left_type == 'VECTOR' and (dot1.handle_right - dot1.co).length < distance: dot1.handle_right_type = "VECTOR" if dot1.handle_right_type == 'VECTOR' and (dot.handle_left - dot.co).length < distance: - dot.handle_left_type = "VECTOR" + dot.handle_left_type = "VECTOR" else: if len(spline.points) > 1: - for i in range(0, len(spline.points)): - + for i in range(0, len(spline.points)): + if i == 0: ii = len(spline.points) - 1 - else: + else: ii = i - 1 - + dot = spline.points[i]; - dot1 = spline.points[ii]; - + dot1 = spline.points[ii]; + while dot1 in dellist and i != ii: ii -= 1 - if ii < 0: + if ii < 0: ii = len(spline.points)-1 dot1 = spline.points[ii] - - if dot.select and dot1.select and (i!=0 or spline.use_cyclic_u): - + + if dot.select and dot1.select and (i!=0 or spline.use_cyclic_u): + if (dot.co-dot1.co).length < distance: dot1.co = (dot.co + dot1.co) / 2 dellist.append(dot) @@ -664,17 +664,17 @@ def main_rd(context, distance = 0.01): for dot in bezier_dellist: dot.select_control_point = True - + for dot in dellist: dot.select = True - + bezier_count = len(bezier_dellist) count = len(dellist) - + bpy.ops.curve.delete(type = 'VERT') - + bpy.ops.curve.select_all(action = 'DESELECT') - + return bezier_count + count diff --git a/curve_tools/__init__.py b/curve_tools/__init__.py index 8de5b7d381d012ca99d8ed153f9c9b2901cd034b..17108ef127c08e0adaf220a12262e5d229ed492d 100644 --- a/curve_tools/__init__.py +++ b/curve_tools/__init__.py @@ -345,11 +345,11 @@ class VIEW3D_PT_CurvePanel(Panel): row.operator("curvetools.scale_reset", text='Scale Reset') row = col.row(align=True) row.operator("curvetools.operatorbirail", text="Birail") - row = col.row(align=True) + row = col.row(align=True) row.operator("curvetools.convert_selected_face_to_bezier", text="Convert selected faces to Bezier") row = col.row(align=True) row.operator("curvetools.convert_bezier_to_surface", text="Convert Bezier to Surface") - + # Extended options box1 = self.layout.box() col = box1.column(align=True) @@ -363,9 +363,9 @@ class VIEW3D_PT_CurvePanel(Panel): row = col.row(align=True) row.operator("curvetools.bezier_cad_subdivide", text="Multi Subdivide") row = col.row(align=True) - row.operator("curvetools.split", text='Split by selected points') + row.operator("curvetools.split", text='Split by selected points') row = col.row(align=True) - row.operator("curvetools.remove_doubles", text='Remove Doubles') + row.operator("curvetools.remove_doubles", text='Remove Doubles') row = col.row(align=True) row.operator("curvetools.add_toolpath_discretize_curve", text="Discretize Curve") row = col.row(align=True) @@ -387,7 +387,7 @@ class VIEW3D_PT_CurvePanel(Panel): row.prop(context.scene.curvetools, "curve_vertcolor", text="") row = col.row(align=True) row.operator("curvetools.show_resolution", text="Run [ESC]") - + # D.1 set spline sequence row = col.row(align=True) row.label(text="Show and rearrange spline sequence:") @@ -444,7 +444,7 @@ class VIEW3D_PT_CurvePanel(Panel): row.label(text="Alt + Shift + mouse click - add spline to select") row = col.row(align=True) row.label(text="A - deselect all") - + # Add-ons Preferences Update Panel # Define Panel classes for updating @@ -492,17 +492,17 @@ class CurveAddonPreferences(AddonPreferences): # Context MENU def curve_tools_context_menu(self, context): bl_label = 'Curve tools' - + self.layout.operator("curvetools.bezier_points_fillet", text="Fillet") self.layout.operator("curvetools.bezier_cad_handle_projection", text='Handle Projection') self.layout.operator("curvetools.bezier_spline_divide", text="Divide") self.layout.operator("curvetools.add_toolpath_offset_curve", text="Offset Curve") self.layout.operator("curvetools.remove_doubles", text='Remove Doubles') self.layout.separator() - + def curve_tools_object_context_menu(self, context): bl_label = 'Curve tools' - + if context.active_object.type == "CURVE": self.layout.operator("curvetools.scale_reset", text="Scale Reset") self.layout.operator("curvetools.add_toolpath_offset_curve", text="Offset Curve") @@ -566,21 +566,21 @@ def register(): default=True, description="Curves Utils" ) - + for cls in classes: bpy.utils.register_class(cls) for panel in panels: bpy.utils.register_class(panel) - + auto_loft.register() - + bpy.types.TOPBAR_MT_file_export.append(menu_file_export) - + bpy.types.Scene.curvetools = bpy.props.PointerProperty(type=curvetoolsSettings) - + update_panel(None, bpy.context) - + bpy.types.VIEW3D_MT_edit_curve_context_menu.prepend(curve_tools_context_menu) bpy.types.VIEW3D_MT_object_context_menu.prepend(curve_tools_object_context_menu) @@ -592,17 +592,17 @@ def unregister(): del bpy.types.Scene.UTAdvancedDrop del bpy.types.Scene.UTExtendedDrop del bpy.types.Scene.UTUtilsDrop - + auto_loft.unregister() - + bpy.types.TOPBAR_MT_file_export.remove(menu_file_export) - + bpy.types.VIEW3D_MT_edit_curve_context_menu.remove(curve_tools_context_menu) bpy.types.VIEW3D_MT_object_context_menu.remove(curve_tools_object_context_menu) - + for panel in panels: bpy.utils.unregister_class(panel) - + for cls in classes: bpy.utils.unregister_class(cls) diff --git a/curve_tools/cad.py b/curve_tools/cad.py index b747845066bb9cad13a98f769cf81883e6b9f4ad..8e62e295ba8d19694b3d140d44aa831b33d1b3f2 100644 --- a/curve_tools/cad.py +++ b/curve_tools/cad.py @@ -70,9 +70,9 @@ class Boolean(bpy.types.Operator): def execute(self, context): current_mode = bpy.context.object.mode - + bpy.ops.object.mode_set(mode = 'EDIT') - + if bpy.context.object.data.dimensions != '2D': self.report({'WARNING'}, 'Can only be applied in 2D') return {'CANCELLED'} @@ -86,9 +86,9 @@ class Boolean(bpy.types.Operator): if not internal.bezierBooleanGeometry(splineA, splineB, self.operation): self.report({'WARNING'}, 'Invalid selection. Only work to selected two spline.') return {'CANCELLED'} - + bpy.ops.object.mode_set (mode = current_mode) - + return {'FINISHED'} class Intersection(bpy.types.Operator): @@ -108,7 +108,7 @@ class Intersection(bpy.types.Operator): internal.bezierMultiIntersection(segments) return {'FINISHED'} - + class HandleProjection(bpy.types.Operator): bl_idname = 'curvetools.bezier_cad_handle_projection' bl_description = bl_label = 'Handle Projection' @@ -191,7 +191,7 @@ class Subdivide(bpy.types.Operator): def execute(self, context): current_mode = bpy.context.object.mode - + bpy.ops.object.mode_set(mode = 'EDIT') segments = internal.bezierSegments(bpy.context.object.data.splines, True) @@ -206,7 +206,7 @@ class Subdivide(bpy.types.Operator): for segment in segments: segment['cuts'].extend(cuts) internal.subdivideBezierSegments(segments) - + bpy.ops.object.mode_set (mode = current_mode) return {'FINISHED'} diff --git a/curve_tools/fillet.py b/curve_tools/fillet.py index 3bb3e492ca0a3256dff374d3ef474436ecf3325a..c9fcb688013cefb42455e30f14e5fffa79a52c4c 100644 --- a/curve_tools/fillet.py +++ b/curve_tools/fillet.py @@ -47,7 +47,7 @@ def remove_handler(handlers): except: pass for handler in handlers: - handlers.remove(handler) + handlers.remove(handler) class Fillet(bpy.types.Operator): @@ -55,44 +55,44 @@ class Fillet(bpy.types.Operator): bl_label = "Curve Fillet" bl_description = "Curve Fillet" bl_options = {'REGISTER', 'UNDO'} - + x: IntProperty(name="x", description="x") y: IntProperty(name="y", description="y") location3D: FloatVectorProperty(name = "", description = "Start location", default = (0.0, 0.0, 0.0), subtype = 'XYZ') - + handlers = [] - + def execute(self, context): self.report({'INFO'}, "ESC or TAB - cancel") bpy.ops.object.mode_set(mode = 'EDIT') - + # color change in the panel self.path_color = bpy.context.scene.curvetools.path_color self.path_thickness = bpy.context.scene.curvetools.path_thickness def modal(self, context, event): context.area.tag_redraw() - + if event.type in {'ESC', 'TAB'}: # Cancel remove_handler(self.handlers) return {'CANCELLED'} - + if event.type in {'X', 'DEL'}: # Cancel remove_handler(self.handlers) - bpy.ops.curve.delete(type='VERT') - return {'RUNNING_MODAL'} - + bpy.ops.curve.delete(type='VERT') + return {'RUNNING_MODAL'} + elif event.alt and event.shift and event.type == 'LEFTMOUSE': click(self, context, event) - + elif event.alt and not event.shift and event.type == 'LEFTMOUSE': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') click(self, context, event) - + elif event.alt and event.type == 'RIGHTMOUSE': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') @@ -100,12 +100,12 @@ class Fillet(bpy.types.Operator): elif event.alt and not event.shift and event.shift and event.type == 'RIGHTMOUSE': click(self, context, event) - + elif event.type == 'A': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') - - elif event.type == 'MOUSEMOVE': # + + elif event.type == 'MOUSEMOVE': # self.x = event.mouse_x self.y = event.mouse_y region = bpy.context.region @@ -115,7 +115,7 @@ class Fillet(bpy.types.Operator): rv3d, (event.mouse_region_x, event.mouse_region_y), (0.0, 0.0, 0.0) - ) + ) return {'PASS_THROUGH'} @@ -123,7 +123,7 @@ class Fillet(bpy.types.Operator): self.execute(context) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} - + @classmethod def poll(cls, context): return (context.object is not None and diff --git a/curve_tools/operators.py b/curve_tools/operators.py index 191aff0873632453ff6ec709d3f020580804053e..aeb4672c2c4441ac6c631da987c068f7a2e62a78 100644 --- a/curve_tools/operators.py +++ b/curve_tools/operators.py @@ -151,8 +151,8 @@ class OperatorOriginToSpline0Start(bpy.types.Operator): def execute(self, context): - - + + blCurve = context.active_object blSpline = blCurve.data.splines[0] newOrigin = blCurve.matrix_world @ blSpline.bezier_points[0].co @@ -162,12 +162,12 @@ class OperatorOriginToSpline0Start(bpy.types.Operator): self.report({'INFO'}, "newOrigin: %.6f, %.6f, %.6f" % (newOrigin.x, newOrigin.y, newOrigin.z)) current_mode = bpy.context.object.mode - + bpy.ops.object.mode_set(mode = 'OBJECT') bpy.context.scene.cursor.location = newOrigin bpy.ops.object.origin_set(type='ORIGIN_CURSOR') bpy.context.scene.cursor.location = origOrigin - + bpy.ops.object.mode_set (mode = current_mode) return {'FINISHED'} @@ -212,16 +212,16 @@ class OperatorIntersectCurves(bpy.types.Operator): bpy.ops.object.select_all(action='DESELECT') selected_objects[i].select_set(True) selected_objects[j].select_set(True) - + if selected_objects[i].type == 'CURVE' and selected_objects[j].type == 'CURVE': curveIntersector = intersections.CurvesIntersector.FromSelection() rvIntersectionNrs = curveIntersector.CalcAndApplyIntersections() self.report({'INFO'}, "Active curve points: %d; other curve points: %d" % (rvIntersectionNrs[0], rvIntersectionNrs[1])) - + for obj in selected_objects: obj.select_set(True) - + return {'FINISHED'} # ------------------------------------------------------------ @@ -415,14 +415,14 @@ class OperatorSplinesJoinNeighbouring(bpy.types.Operator): self.report({'INFO'}, "Applied %d joins on %d splines; resulting nrSplines: %d" % (nrJoins, nrSplines, curve.nrSplines)) return {'FINISHED'} - + # ------------------------------------------------------------ # SurfaceFromBezier def SurfaceFromBezier(surfacedata, points, center): - + len_points = len(points) - 1 - + if len_points % 2 == 0: h = mathematics.subdivide_cubic_bezier( points[len_points].co, points[len_points].handle_right, @@ -435,7 +435,7 @@ def SurfaceFromBezier(surfacedata, points, center): points[len_points].co = h[2] points[len_points].handle_right = h[3] points[0].handle_left = h[4] - + half = round((len_points + 1)/2) - 1 # 1 surfacespline1 = surfacedata.splines.new(type='NURBS') @@ -450,7 +450,7 @@ def SurfaceFromBezier(surfacedata, points, center): surfacespline1.use_endpoint_v = True for i in range(0, half): - + if center: # 2 surfacespline2 = surfacedata.splines.new(type='NURBS') @@ -467,7 +467,7 @@ def SurfaceFromBezier(surfacedata, points, center): p.select = True surfacespline2.use_endpoint_u = True surfacespline2.use_endpoint_v = True - + # 3 surfacespline3 = surfacedata.splines.new(type='NURBS') surfacespline3.points.add(3) @@ -483,7 +483,7 @@ def SurfaceFromBezier(surfacedata, points, center): p.select = True surfacespline3.use_endpoint_u = True surfacespline3.use_endpoint_v = True - + # 4 surfacespline4 = surfacedata.splines.new(type='NURBS') surfacespline4.points.add(3) @@ -499,7 +499,7 @@ def SurfaceFromBezier(surfacedata, points, center): p.select = True surfacespline4.use_endpoint_u = True surfacespline4.use_endpoint_v = True - + if center: # 5 surfacespline5 = surfacedata.splines.new(type='NURBS') @@ -516,7 +516,7 @@ def SurfaceFromBezier(surfacedata, points, center): p.select = True surfacespline5.use_endpoint_u = True surfacespline5.use_endpoint_v = True - + # 6 surfacespline6 = surfacedata.splines.new(type='NURBS') surfacespline6.points.add(3) @@ -528,10 +528,10 @@ def SurfaceFromBezier(surfacedata, points, center): p.select = True surfacespline6.use_endpoint_u = True surfacespline6.use_endpoint_v = True - - bpy.ops.object.mode_set(mode = 'EDIT') + + bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.curve.make_segment() - + for s in surfacedata.splines: s.resolution_u = 4 s.resolution_v = 4 @@ -561,7 +561,7 @@ class ConvertSelectedFacesToBezier(bpy.types.Operator): curvedata = bpy.data.curves.new('Curve' + active_object.name, type='CURVE') curveobject = object_utils.object_data_add(context, curvedata) curvedata.dimensions = '3D' - + for poly in meshdata.polygons: if poly.select: newSpline = curvedata.splines.new(type='BEZIER') @@ -576,9 +576,9 @@ class ConvertSelectedFacesToBezier(bpy.types.Operator): newSpline.bezier_points[npoint].select_left_handle = True newSpline.bezier_points[npoint].select_right_handle = True npoint += 1 - + return {'FINISHED'} - + # ------------------------------------------------------------ # Convert Bezier to Surface @@ -593,7 +593,7 @@ class ConvertBezierToSurface(bpy.types.Operator): default=False, description="Consider center points" ) - + Resolution_U: IntProperty( name="Resolution_U", default=4, @@ -601,7 +601,7 @@ class ConvertBezierToSurface(bpy.types.Operator): soft_min=1, description="Surface resolution U" ) - + Resolution_V: IntProperty( name="Resolution_V", default=4, @@ -609,7 +609,7 @@ class ConvertBezierToSurface(bpy.types.Operator): soft_min=1, description="Surface resolution V" ) - + def draw(self, context): layout = self.layout @@ -618,17 +618,17 @@ class ConvertBezierToSurface(bpy.types.Operator): col.prop(self, 'Center') col.prop(self, 'Resolution_U') col.prop(self, 'Resolution_V') - + @classmethod def poll(cls, context): return util.Selected1OrMoreCurves() def execute(self, context): # main function - bpy.ops.object.mode_set(mode = 'OBJECT') + bpy.ops.object.mode_set(mode = 'OBJECT') active_object = context.active_object curvedata = active_object.data - + surfacedata = bpy.data.curves.new('Surface', type='SURFACE') surfaceobject = object_utils.object_data_add(context, surfacedata) surfaceobject.matrix_world = active_object.matrix_world @@ -636,10 +636,10 @@ class ConvertBezierToSurface(bpy.types.Operator): surfacedata.dimensions = '3D' surfaceobject.show_wire = True surfaceobject.show_in_front = True - + for spline in curvedata.splines: SurfaceFromBezier(surfacedata, spline.bezier_points, self.Center) - + for spline in surfacedata.splines: len_p = len(spline.points) len_devide_4 = round(len_p / 4) + 1 @@ -648,12 +648,12 @@ class ConvertBezierToSurface(bpy.types.Operator): for point_index in range(len_devide_4, len_p - len_devide_4): if point_index != len_devide_2 and point_index != len_devide_2 - 1: spline.points[point_index].select = True - + surfacedata.resolution_u = self.Resolution_U surfacedata.resolution_v = self.Resolution_V return {'FINISHED'} - + # ------------------------------------------------------------ # Fillet @@ -693,10 +693,10 @@ class BezierPointsFillet(bpy.types.Operator): # main function if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='EDIT') - + splines = bpy.context.object.data.splines bpy.ops.curve.spline_type_set(type='BEZIER') - + bpy.ops.curve.handle_type_set(type='VECTOR') s = [] for spline in splines: @@ -719,9 +719,9 @@ class BezierPointsFillet(bpy.types.Operator): jn = 0 for j in ii: j += jn - + bpy.ops.curve.select_all(action='DESELECT') - + if j != 0 and j != n - 1: bezier_points[j].select_control_point = True bezier_points[j + 1].select_control_point = True @@ -730,7 +730,7 @@ class BezierPointsFillet(bpy.types.Operator): bezier_points[j + 1], bezier_points[j + 2]] jn += 1 n += 1 - + elif j == 0: bezier_points[j].select_control_point = True bezier_points[j + 1].select_control_point = True @@ -739,14 +739,14 @@ class BezierPointsFillet(bpy.types.Operator): bezier_points[1], bezier_points[2]] jn += 1 n += 1 - + elif j == n - 1: bezier_points[j].select_control_point = True bezier_points[j - 1].select_control_point = True bpy.ops.curve.subdivide() selected4 = [bezier_points[0], bezier_points[n], bezier_points[n - 1], bezier_points[n - 2]] - + selected4[2].co = selected4[1].co s1 = Vector(selected4[0].co) - Vector(selected4[1].co) s2 = Vector(selected4[3].co) - Vector(selected4[2].co) @@ -756,7 +756,7 @@ class BezierPointsFillet(bpy.types.Operator): s2.normalize() s22 = Vector(selected4[2].co) + s2 * self.Fillet_radius selected4[2].co = s22 - + if self.Fillet_Type == 'Round': if j != n - 1: selected4[2].handle_right_type = 'VECTOR' @@ -829,9 +829,9 @@ class BezierDivide(bpy.types.Operator): if n > 2: jn = 0 for j in ii: - + bpy.ops.curve.select_all(action='DESELECT') - + if (j in ii) and (j + 1 in ii): bezier_points[j + jn].select_control_point = True bezier_points[j + 1 + jn].select_control_point = True @@ -850,7 +850,7 @@ class BezierDivide(bpy.types.Operator): bezier_points[j + 2 + jn].handle_left_type = 'FREE' bezier_points[j + 2 + jn].handle_left = h[4] jn += 1 - + if j == n - 1 and (0 in ii) and spline.use_cyclic_u: bezier_points[j + jn].select_control_point = True bezier_points[0].select_control_point = True @@ -867,12 +867,12 @@ class BezierDivide(bpy.types.Operator): bezier_points[j + 1 + jn].handle_right_type = 'FREE' bezier_points[j + 1 + jn].handle_right = h[3] bezier_points[0].handle_left_type = 'FREE' - bezier_points[0].handle_left = h[4] + bezier_points[0].handle_left = h[4] sn += 1 return {'FINISHED'} - + # ------------------------------------------------------------ # CurveScaleReset Operator @@ -890,25 +890,25 @@ class CurveScaleReset(bpy.types.Operator): def execute(self, context): # main function current_mode = bpy.context.object.mode - + bpy.ops.object.mode_set(mode = 'OBJECT') - + oldCurve = context.active_object oldCurveName = oldCurve.name - + bpy.ops.object.duplicate_move(OBJECT_OT_duplicate=None, TRANSFORM_OT_translate=None) newCurve = context.active_object newCurve.data.splines.clear() newCurve.scale = (1.0, 1.0, 1.0) - + oldCurve.select_set(True) newCurve.select_set(True) bpy.context.view_layer.objects.active = newCurve bpy.ops.object.join() - + joinCurve = context.active_object joinCurve.name = oldCurveName - + bpy.ops.object.mode_set (mode = current_mode) return {'FINISHED'} @@ -927,7 +927,7 @@ class Split(bpy.types.Operator): def execute(self, context): selected_Curves = util.GetSelectedCurves() - + for curve in selected_Curves: spline_points = [] select_points = {} @@ -942,7 +942,7 @@ class Split(bpy.types.Operator): for i in range(len(spline.bezier_points)): bezier_point = spline.bezier_points[i] points[i]=[bezier_point.co[:], bezier_point.handle_left[:], bezier_point.handle_right[:]] - + if spline.bezier_points[i].select_control_point: select_bezier_points[i_bp].append(i) i_bp+=1 @@ -957,24 +957,24 @@ class Split(bpy.types.Operator): select_points[i_p].append(i) i_p+=1 spline_points.append(points) - + curve.data.splines.clear() - + for key in select_bezier_points: - + num=0 - + if select_bezier_points[key][-1] == select_bezier_points[key][0]-1: select_bezier_points[key].pop() - + for i in select_bezier_points[key][1:]+[select_bezier_points[key][0]-1]: if i != 0: spline = curve.data.splines.new('BEZIER') spline.bezier_points.add(i-num) - + for j in range(num, i): bezier_point = spline.bezier_points[j-num] - + bezier_point.co = bezier_spline_points[key][j][0] bezier_point.handle_left = bezier_spline_points[key][j][1] bezier_point.handle_right = bezier_spline_points[key][j][2] @@ -983,29 +983,29 @@ class Split(bpy.types.Operator): bezier_point.handle_left = bezier_spline_points[key][i][1] bezier_point.handle_right = bezier_spline_points[key][i][2] num=i - + for key in select_points: - + num=0 - + if select_points[key][-1] == select_points[key][0]-1: select_points[key].pop() - + for i in select_points[key][1:]+[select_points[key][0]-1]: if i != 0: spline = curve.data.splines.new(spline_points[key][i][1]) spline.points.add(i-num) - + for j in range(num, i): point = spline.points[j-num] - + point.co = spline_points[key][j][0] point = spline.points[-1] point.co = spline_points[key][i][0] num=i - + return {'FINISHED'} - + class SeparateOutline(bpy.types.Operator): bl_idname = "curvetools.sep_outline" bl_label = "Separate Outline" @@ -1021,7 +1021,7 @@ class SeparateOutline(bpy.types.Operator): bpy.ops.curve.separate() return {'FINISHED'} - + class CurveBoolean(bpy.types.Operator): bl_idname = "curvetools.bezier_curve_boolean" bl_description = "Curve Boolean" @@ -1043,7 +1043,7 @@ class CurveBoolean(bpy.types.Operator): @classmethod def poll(cls, context): return util.Selected1OrMoreCurves() - + def draw(self, context): layout = self.layout @@ -1055,27 +1055,27 @@ class CurveBoolean(bpy.types.Operator): def execute(self, context): current_mode = bpy.context.object.mode - + if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode = 'OBJECT') - + selected_Curves = util.GetSelectedCurves() len_selected_curves = len(selected_Curves) if len_selected_curves < 2: return {'FINISHED'} - + min_number = 1 - + max_number = 0 for iCurve in range(0, len_selected_curves): len_splines = len(selected_Curves[iCurve].data.splines) max_number += len_splines - + if self.number < min_number: self.number = min_number if self.number > max_number: self.number = max_number - + j = 0 first_curve = 0 first_spline = 0 @@ -1086,14 +1086,14 @@ class CurveBoolean(bpy.types.Operator): first_curve = iCurve first_spline = iSpline j += 1 - + bpy.ops.object.select_all(action='DESELECT') - + spline1 = selected_Curves[first_curve].data.splines[first_spline] matrix_world1 = selected_Curves[first_curve].matrix_world - + len_spline1 = len(spline1.bezier_points) - + dataCurve = bpy.data.curves.new(self.operation, type='CURVE') dataCurve.dimensions = '2D' newSpline1 = dataCurve.splines.new(type='BEZIER') @@ -1105,7 +1105,7 @@ class CurveBoolean(bpy.types.Operator): newSpline1.bezier_points[n].handle_left = matrix_world1 @ spline1.bezier_points[n].handle_left newSpline1.bezier_points[n].handle_right_type = spline1.bezier_points[n].handle_right_type newSpline1.bezier_points[n].handle_right = matrix_world1 @ spline1.bezier_points[n].handle_right - + Curve = object_utils.object_data_add(context, dataCurve) bpy.context.view_layer.objects.active = Curve Curve.select_set(True) @@ -1129,7 +1129,7 @@ class CurveBoolean(bpy.types.Operator): newSpline.bezier_points[n].handle_left = matrix_world @ spline.bezier_points[n].handle_left newSpline.bezier_points[n].handle_right_type = spline.bezier_points[n].handle_right_type newSpline.bezier_points[n].handle_right = matrix_world @ spline.bezier_points[n].handle_right - + bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.curve.select_all(action='SELECT') splines = internal.getSelectedSplines(True, True) @@ -1138,15 +1138,15 @@ class CurveBoolean(bpy.types.Operator): splineA = splines[0] splineB = splines[1] dataCurve.splines.active = newSpline1 - + if not internal.bezierBooleanGeometry(splineA, splineB, self.operation): self.report({'WARNING'}, 'Invalid selection.') return {'CANCELLED'} - + j += 1 - + bpy.ops.object.mode_set (mode = current_mode) - + return {'FINISHED'} def register(): diff --git a/curve_tools/outline.py b/curve_tools/outline.py index 3975a40366633f88694204ce7530bd78e5b8126a..b1f8561e04da5a243f111c9470acb13acfab5dd6 100644 --- a/curve_tools/outline.py +++ b/curve_tools/outline.py @@ -44,49 +44,49 @@ def createOutline(curve, outline): if len(p) < 2: return out = [] - + n = ((p[0].handle_right - p[0].co).normalized() - (p[0].handle_left - p[0].co).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = p[0].co + outline * n out.append(o) - + for i in range(1,len(p)-1): n = ((p[i].handle_right - p[i].co).normalized() - (p[i].handle_left - p[i].co).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = intersect_line_line(out[-1], (out[-1]+p[i].co - p[i-1].co), p[i].co, p[i].co + n)[0] out.append(o) - + n = ((p[-1].handle_right - p[-1].co).normalized() - (p[-1].handle_left - p[-1].co).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = p[-1].co + outline * n out.append(o) - + curve.data.splines.new(spline.type) if spline.use_cyclic_u: curve.data.splines[-1].use_cyclic_u = True p_out = curve.data.splines[-1].bezier_points p_out.add(len(out)-1) - + for i in range(len(out)): p_out[i].handle_left_type = 'FREE' p_out[i].handle_right_type = 'FREE' - + p_out[i].co = out[i] - + if i<len(out)-1: l = (p[i + 1].co - p[i].co).length l2 = (out[i] - out[i + 1]).length - + if i==0: p_out[i].handle_left = out[i] + ((p[i].handle_left - p[i].co) * l2/l) if i<len(out)-1: p_out[i + 1].handle_left = out[i + 1] + ((p[i + 1].handle_left - p[i + 1].co) * l2/l) p_out[i].handle_right = out[i] + ((p[i].handle_right - p[i].co) * l2/l) - + for i in range(len(p)): p_out[i].handle_left_type = p[i].handle_left_type p_out[i].handle_right_type = p[i].handle_right_type - + else: if len(spline.points) < 2: return @@ -95,32 +95,32 @@ def createOutline(curve, outline): v = Vector((point.co[0], point.co[1], point.co[2])) p.append(v) out = [] - + n = ((p[1] - p[0]).normalized() - (p[-1] - p[0]).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = p[0] + outline * n out.append(o) - + for i in range(1,len(p)-1): n = ((p[i+1] - p[i]).normalized() - (p[i-1] - p[i]).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = intersect_line_line(out[-1], (out[-1]+p[i] - p[i-1]), p[i], p[i] + n)[0] out.append(o) - + n = ((p[0] - p[-1]).normalized() - (p[-2] - p[-1]).normalized()).normalized() n = Vector((-n[1], n[0], n[2])) o = p[-1] + outline * n out.append(o) - + curve.data.splines.new(spline.type) if spline.use_cyclic_u: curve.data.splines[-1].use_cyclic_u = True p_out = curve.data.splines[-1].points p_out.add(len(out)-1) - - for i in range(len(out)): + + for i in range(len(out)): p_out[i].co = (out[i][0], out[i][1], out[i][2], 0.0) - + return diff --git a/curve_tools/path_finder.py b/curve_tools/path_finder.py index 30c673e0c06f5e4b5863336f44a870fa7c6d2d9d..9093f5f26eae8c28b6e50b1c77c0560dbe943c41 100644 --- a/curve_tools/path_finder.py +++ b/curve_tools/path_finder.py @@ -27,7 +27,7 @@ bl_info = { 'wiki_url': '', 'tracker_url': '', 'category': 'Curve'} - + import time import threading @@ -69,7 +69,7 @@ def get_bezier_points(spline, matrix_world): point_list.extend([matrix_world @ spline.bezier_points[0].co]) return point_list - + def get_points(spline, matrix_world): point_list = [] len_points = len(spline.points) @@ -92,25 +92,25 @@ def get_points(spline, matrix_world): return point_list def draw_bezier_points(self, context, spline, matrix_world, path_color, path_thickness): - + points = get_bezier_points(spline, matrix_world) - + shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'POINTS', {"pos": points}) - + shader.bind() shader.uniform_float("color", path_color) bgl.glEnable(bgl.GL_BLEND) bgl.glLineWidth(path_thickness) batch.draw(shader) - + def draw_points(self, context, spline, matrix_world, path_color, path_thickness): - + points = get_points(spline, matrix_world) - + shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'POINTS', {"pos": points}) - + shader.bind() shader.uniform_float("color", path_color) bgl.glEnable(bgl.GL_BLEND) @@ -131,7 +131,7 @@ def near(location3D, point, radius): factor += 1 if point.z < (location3D.z + radius): factor += 1 - + return factor def click(self, context, event): @@ -141,9 +141,9 @@ def click(self, context, event): matrix_world = object.matrix_world if object.type == 'CURVE': curvedata = object.data - + radius = bpy.context.scene.curvetools.PathFinderRadius - + for spline in curvedata.splines: len_bezier_points = len(spline.bezier_points) factor_max = 0 @@ -153,7 +153,7 @@ def click(self, context, event): factor = near(self.location3D, co, radius) if factor > factor_max: factor_max = factor - + if i < len_bezier_points - 1: for t in range(0, 100, 2): h = mathematics.subdivide_cubic_bezier(spline.bezier_points[i].co, @@ -186,7 +186,7 @@ def click(self, context, event): bezier_point.select_control_point = True bezier_point.select_left_handle = True bezier_point.select_right_handle = True - + for spline in curvedata.splines: len_points = len(spline.points) factor_max = 0 @@ -219,7 +219,7 @@ def click(self, context, event): if factor_max == 6: args = (self, context, spline, matrix_world, self.path_color, self.path_thickness) self.handlers.append(bpy.types.SpaceView3D.draw_handler_add(draw_points, args, 'WINDOW', 'POST_VIEW')) - + for point in spline.points: point.select = True @@ -230,51 +230,51 @@ def remove_handler(handlers): except: pass for handler in handlers: - handlers.remove(handler) + handlers.remove(handler) class PathFinder(bpy.types.Operator): bl_idname = "curvetools.pathfinder" bl_label = "Path Finder" bl_description = "Path Finder" bl_options = {'REGISTER', 'UNDO'} - + x: IntProperty(name="x", description="x") y: IntProperty(name="y", description="y") location3D: FloatVectorProperty(name = "", description = "Start location", default = (0.0, 0.0, 0.0), subtype = 'XYZ') - + handlers = [] - + def execute(self, context): self.report({'INFO'}, "ESC or TAB - cancel") bpy.ops.object.mode_set(mode = 'EDIT') - + # color change in the panel self.path_color = bpy.context.scene.curvetools.path_color self.path_thickness = bpy.context.scene.curvetools.path_thickness def modal(self, context, event): context.area.tag_redraw() - + if event.type in {'ESC', 'TAB'}: # Cancel remove_handler(self.handlers) return {'CANCELLED'} - + if event.type in {'X', 'DEL'}: # Cancel remove_handler(self.handlers) - bpy.ops.curve.delete(type='VERT') - return {'RUNNING_MODAL'} - + bpy.ops.curve.delete(type='VERT') + return {'RUNNING_MODAL'} + elif event.alt and event.shift and event.type == 'LEFTMOUSE': click(self, context, event) - + elif event.alt and not event.shift and event.type == 'LEFTMOUSE': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') click(self, context, event) - + elif event.alt and event.type == 'RIGHTMOUSE': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') @@ -282,12 +282,12 @@ class PathFinder(bpy.types.Operator): elif event.alt and not event.shift and event.shift and event.type == 'RIGHTMOUSE': click(self, context, event) - + elif event.type == 'A': remove_handler(self.handlers) bpy.ops.curve.select_all(action='DESELECT') - - elif event.type == 'MOUSEMOVE': # + + elif event.type == 'MOUSEMOVE': # self.x = event.mouse_x self.y = event.mouse_y region = bpy.context.region @@ -297,7 +297,7 @@ class PathFinder(bpy.types.Operator): rv3d, (event.mouse_region_x, event.mouse_region_y), (0.0, 0.0, 0.0) - ) + ) return {'PASS_THROUGH'} @@ -305,7 +305,7 @@ class PathFinder(bpy.types.Operator): self.execute(context) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} - + @classmethod def poll(cls, context): return util.Selected1OrMoreCurves() diff --git a/curve_tools/remove_doubles.py b/curve_tools/remove_doubles.py index cf955980be39fb7275d7705318379a99006462e3..d69b3e0aff384534bb0b2a201cdea4507474944e 100644 --- a/curve_tools/remove_doubles.py +++ b/curve_tools/remove_doubles.py @@ -12,70 +12,70 @@ bl_info = { } def main(context, distance = 0.01): - + selected_Curves = util.GetSelectedCurves() if bpy.ops.object.mode_set.poll(): bpy.ops.object.mode_set(mode='EDIT') - + for curve in selected_Curves: bezier_dellist = [] dellist = [] - - for spline in curve.data.splines: + + for spline in curve.data.splines: if spline.type == 'BEZIER': if len(spline.bezier_points) > 1: - for i in range(0, len(spline.bezier_points)): - + for i in range(0, len(spline.bezier_points)): + if i == 0: ii = len(spline.bezier_points) - 1 - else: + else: ii = i - 1 - + dot = spline.bezier_points[i]; - dot1 = spline.bezier_points[ii]; - + dot1 = spline.bezier_points[ii]; + while dot1 in bezier_dellist and i != ii: ii -= 1 - if ii < 0: + if ii < 0: ii = len(spline.bezier_points)-1 dot1 = spline.bezier_points[ii] - - if dot.select_control_point and dot1.select_control_point and (i!=0 or spline.use_cyclic_u): - + + if dot.select_control_point and dot1.select_control_point and (i!=0 or spline.use_cyclic_u): + if (dot.co-dot1.co).length < distance: # remove points and recreate hangles dot1.handle_right_type = "FREE" dot1.handle_right = dot.handle_right dot1.co = (dot.co + dot1.co) / 2 bezier_dellist.append(dot) - + else: # Handles that are on main point position converts to vector, # if next handle are also vector if dot.handle_left_type == 'VECTOR' and (dot1.handle_right - dot1.co).length < distance: dot1.handle_right_type = "VECTOR" if dot1.handle_right_type == 'VECTOR' and (dot.handle_left - dot.co).length < distance: - dot.handle_left_type = "VECTOR" + dot.handle_left_type = "VECTOR" else: if len(spline.points) > 1: - for i in range(0, len(spline.points)): - + for i in range(0, len(spline.points)): + if i == 0: ii = len(spline.points) - 1 - else: + else: ii = i - 1 - + dot = spline.points[i]; - dot1 = spline.points[ii]; - + dot1 = spline.points[ii]; + while dot1 in dellist and i != ii: ii -= 1 - if ii < 0: + if ii < 0: ii = len(spline.points)-1 dot1 = spline.points[ii] - - if dot.select and dot1.select and (i!=0 or spline.use_cyclic_u): - + + if dot.select and dot1.select and (i!=0 or spline.use_cyclic_u): + if (dot.co-dot1.co).length < distance: dot1.co = (dot.co + dot1.co) / 2 dellist.append(dot) @@ -84,19 +84,19 @@ def main(context, distance = 0.01): for dot in bezier_dellist: dot.select_control_point = True - + for dot in dellist: dot.select = True - + bezier_count = len(bezier_dellist) count = len(dellist) - + bpy.ops.curve.delete(type = 'VERT') - + bpy.ops.curve.select_all(action = 'DESELECT') - + return bezier_count + count - + class CurveRemvDbs(bpy.types.Operator): diff --git a/curve_tools/show_resolution.py b/curve_tools/show_resolution.py index 78acc1e34281ab2dd882ed6e6408a3e768c920f8..fc8fdad22d846742931cf48feeb85bf1747f3bec 100644 --- a/curve_tools/show_resolution.py +++ b/curve_tools/show_resolution.py @@ -38,41 +38,41 @@ def get_points(spline, matrix_world): bezier_points = spline.bezier_points - if len(bezier_points) < 2: + if len(bezier_points) < 2: return [] r = spline.resolution_u + 1 if r < 2: return [] segments = len(bezier_points) - + if not spline.use_cyclic_u: segments -= 1 - + point_list = [] for i in range(segments): inext = (i + 1) % len(bezier_points) - + bezier_points1 = matrix_world @ bezier_points[i].co handle1 = matrix_world @ bezier_points[i].handle_right handle2 = matrix_world @ bezier_points[inext].handle_left bezier_points2 = matrix_world @ bezier_points[inext].co - + bezier = bezier_points1, handle1, handle2, bezier_points2, r points = interpolate_bezier(*bezier) point_list.extend(points) - + return point_list - + def draw(self, context, splines, curve_vertcolor, matrix_world): - + for spline in splines: points = get_points(spline, matrix_world) - + shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'POINTS', {"pos": points}) - + shader.bind() shader.uniform_float("color", curve_vertcolor) batch.draw(shader) @@ -82,13 +82,13 @@ class ShowCurveResolution(bpy.types.Operator): bl_idname = "curvetools.show_resolution" bl_label = "Show Curve Resolution" bl_description = "Show curve Resolution / [ESC] - remove" - + handlers = [] - + def modal(self, context, event): context.area.tag_redraw() - if event.type in {'ESC'}: + if event.type in {'ESC'}: for handler in self.handlers: try: bpy.types.SpaceView3D.draw_handler_remove(handler, 'WINDOW') @@ -104,16 +104,16 @@ class ShowCurveResolution(bpy.types.Operator): def invoke(self, context, event): if context.area.type == 'VIEW_3D': - + # color change in the panel curve_vertcolor = bpy.context.scene.curvetools.curve_vertcolor - + splines = context.active_object.data.splines matrix_world = context.active_object.matrix_world - + # the arguments we pass the the callback args = (self, context, splines, curve_vertcolor, matrix_world) - + # Add the region OpenGL drawing callback # draw in view space with 'POST_VIEW' and 'PRE_VIEW' self.handlers.append(bpy.types.SpaceView3D.draw_handler_add(draw, args, 'WINDOW', 'POST_VIEW')) @@ -121,10 +121,10 @@ class ShowCurveResolution(bpy.types.Operator): context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: - self.report({'WARNING'}, + self.report({'WARNING'}, "View3D not found, cannot run operator") return {'CANCELLED'} - + @classmethod def poll(cls, context): return (context.object is not None and diff --git a/curve_tools/splines_sequence.py b/curve_tools/splines_sequence.py index 5d11aedffbe8660a500979cb0b85eac18b0c8989..d861a1ee894d843bc478820da32252edda97ebc7 100644 --- a/curve_tools/splines_sequence.py +++ b/curve_tools/splines_sequence.py @@ -39,7 +39,7 @@ from bpy.props import ( def draw_number(n, co, font_height): point_list = [] - + numeral = [ [Vector((0, 0, 0)), Vector((0, 2, 0)), Vector((0, 2, 0)), Vector((1, 2, 0)), Vector((1, 2, 0)), Vector((1, 0, 0)), Vector((1, 0, 0)), Vector((0, 0, 0))], [Vector((0, 1, 0)), Vector((1, 2, 0)), Vector((1, 2, 0)), Vector((1, 0, 0))], @@ -52,20 +52,20 @@ def draw_number(n, co, font_height): [Vector((0, 1, 0)), Vector((0, 2, 0)), Vector((0, 2, 0)), Vector((1, 2, 0)), Vector((1, 2, 0)), Vector((1, 0, 0)), Vector((1, 0, 0)), Vector((0, 0, 0)), Vector((0, 0, 0)), Vector((0, 1, 0)), Vector((0, 1, 0)), Vector((1, 1, 0))], [Vector((0, 0, 0)), Vector((1, 1, 0)), Vector((1, 1, 0)), Vector((1, 2, 0)), Vector((1, 2, 0)), Vector((0, 2, 0)), Vector((0, 2, 0)), Vector((0, 1, 0)), Vector((0, 1, 0)), Vector((1, 1, 0))], ] - + for num in numeral[n]: point_list.extend([num * font_height + co]) - + return point_list - + def draw(self, context, splines, sequence_color, font_thickness, font_size, matrix_world): splines_len = len(splines) for n in range(0, splines_len): - + res = [int(x) for x in str(n)] - + i = 0 for r in res: # draw some text @@ -74,14 +74,14 @@ def draw(self, context, splines, sequence_color, font_thickness, font_size, matr else: first_point = matrix_world @ splines[n].points[0].co first_point_co = Vector((first_point.x, first_point.y, first_point.z)) - + first_point_co = Vector((i, 0, 0)) + first_point_co points = draw_number(r, first_point_co, font_size) - + shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos": points}) - + shader.bind() bgl.glLineWidth(font_thickness) shader.uniform_float("color", sequence_color) @@ -92,13 +92,13 @@ class ShowSplinesSequence(bpy.types.Operator): bl_idname = "curvetools.show_splines_sequence" bl_label = "Show Splines Sequence" bl_description = "Show Splines Sequence / [ESC] - remove" - + handlers = [] - + def modal(self, context, event): context.area.tag_redraw() - if event.type in {'ESC'}: + if event.type in {'ESC'}: for handler in self.handlers: try: bpy.types.SpaceView3D.draw_handler_remove(handler, 'WINDOW') @@ -114,18 +114,18 @@ class ShowSplinesSequence(bpy.types.Operator): def invoke(self, context, event): if context.area.type == 'VIEW_3D': - + # color change in the panel sequence_color = bpy.context.scene.curvetools.sequence_color font_thickness = bpy.context.scene.curvetools.font_thickness font_size = bpy.context.scene.curvetools.font_size - + splines = context.active_object.data.splines matrix_world = context.active_object.matrix_world - + # the arguments we pass the the callback args = (self, context, splines, sequence_color, font_thickness, font_size, matrix_world) - + # Add the region OpenGL drawing callback # draw in view space with 'POST_VIEW' and 'PRE_VIEW' self.handlers.append(bpy.types.SpaceView3D.draw_handler_add(draw, args, 'WINDOW', 'POST_VIEW')) @@ -133,7 +133,7 @@ class ShowSplinesSequence(bpy.types.Operator): context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: - self.report({'WARNING'}, + self.report({'WARNING'}, "View3D not found, cannot run operator") return {'CANCELLED'} @@ -149,17 +149,17 @@ def rearrangesplines(dataCurve, select_spline1, select_spline2): spline1 = dataCurve.splines[select_spline1] spline2 = dataCurve.splines[select_spline2] - + bpy.ops.curve.select_all(action='SELECT') bpy.ops.curve.spline_type_set(type='BEZIER') bpy.ops.curve.select_all(action='DESELECT') type1 = spline1.type type2 = spline2.type - + len_spline1 = len(spline1.bezier_points) len_spline2 = len(spline2.bezier_points) - + newSpline = dataCurve.splines.new(type=type1) newSpline.bezier_points.add(len_spline1 - 1) newSpline.use_cyclic_u = spline1.use_cyclic_u @@ -170,7 +170,7 @@ def rearrangesplines(dataCurve, select_spline1, select_spline2): newSpline.bezier_points[n].handle_right_type = spline1.bezier_points[n].handle_right_type newSpline.bezier_points[n].handle_right = spline1.bezier_points[n].handle_right spline1.bezier_points[n].select_control_point = True - + spline1.bezier_points[0].select_control_point = False spline1.bezier_points[0].select_left_handle = False spline1.bezier_points[0].select_right_handle = False @@ -178,7 +178,7 @@ def rearrangesplines(dataCurve, select_spline1, select_spline2): spline1.bezier_points[0].select_control_point = True bpy.ops.curve.spline_type_set(type=type2) - + bpy.ops.curve.select_all(action='DESELECT') spline1.bezier_points.add(len_spline2 - 1) @@ -193,12 +193,12 @@ def rearrangesplines(dataCurve, select_spline1, select_spline2): spline1.bezier_points[n].select_left_handle = False spline1.bezier_points[n].select_right_handle = False spline2.bezier_points[n].select_control_point = True - + spline2.bezier_points[0].select_control_point = False spline2.bezier_points[0].select_left_handle = False spline2.bezier_points[0].select_right_handle = False bpy.ops.curve.delete(type='VERT') - + spline2.bezier_points[0].select_control_point = True bpy.ops.curve.spline_type_set(type=type1) @@ -210,29 +210,29 @@ def rearrangesplines(dataCurve, select_spline1, select_spline2): spline2.bezier_points[m].handle_left = newSpline.bezier_points[m].handle_left spline2.bezier_points[m].handle_right_type = newSpline.bezier_points[m].handle_right_type spline2.bezier_points[m].handle_right = newSpline.bezier_points[m].handle_right - + bpy.ops.curve.select_all(action='DESELECT') for point in newSpline.bezier_points: point.select_control_point = True bpy.ops.curve.delete(type='VERT') spline2.bezier_points[0].select_control_point = True - + def rearrange(dataCurve, select_spline, command): len_splines = len(dataCurve.splines) if command == 'NEXT': if select_spline < len_splines - 1: rearrangesplines(dataCurve, select_spline + 1, select_spline) - + if command == 'PREV': if select_spline > 0: rearrangesplines(dataCurve, select_spline, select_spline - 1) - + class RearrangeSpline(bpy.types.Operator): bl_idname = "curvetools.rearrange_spline" bl_label = "Rearrange Spline" bl_description = "Rearrange Spline" - + Types = [('NEXT', "Next", "next"), ('PREV', "Prev", "prev")] command : EnumProperty( @@ -240,17 +240,17 @@ class RearrangeSpline(bpy.types.Operator): description="Command (prev or next)", items=Types ) - + def execute(self, context): bpy.ops.object.mode_set(mode = 'EDIT') bpy.context.view_layer.update() - + dataCurve = context.active_object.data - + splines = context.active_object.data.splines - + select_spline = 0 - + sn = 0 for spline in splines: for bezier_points in spline.bezier_points: @@ -264,9 +264,9 @@ class RearrangeSpline(bpy.types.Operator): if point.select: select_spline = sn sn += 1 - + rearrange(dataCurve, select_spline, self.command) - + return {'FINISHED'} @classmethod diff --git a/curve_tools/util.py b/curve_tools/util.py index 305966979d9724249c35ac021ffeb3c768863159..110b8b8347aca0ecc3ab4b3578ba099c04bafde3 100644 --- a/curve_tools/util.py +++ b/curve_tools/util.py @@ -12,8 +12,8 @@ def GetSelectedCurves(): pass return rvList - - + + def GetSelectedMeshes(): rvList = [] @@ -84,7 +84,7 @@ def Selected1OrMoreCurves(): pass return False - + def Selected2OrMoreCurves(): try: if len(GetSelectedCurves()) > 1: diff --git a/development_edit_operator.py b/development_edit_operator.py index f0766b990044223b25dbb8993fe872702fb79472..884050cf7b5cbada9fbc1241c9b8ed8ee510987f 100644 --- a/development_edit_operator.py +++ b/development_edit_operator.py @@ -40,7 +40,7 @@ from bpy.types import ( Menu, PropertyGroup ) -from bpy.props import ( +from bpy.props import ( EnumProperty, StringProperty, IntProperty @@ -55,7 +55,7 @@ def stdlib_excludes(): for nm in files: if nm != '__init__.py' and nm[-3:] == '.py': excludes.append(os.path.join(top, nm)[len(std_lib)+1:-3].replace('\\','.')) - + return excludes def make_loc(prefix, c): @@ -63,19 +63,19 @@ def make_loc(prefix, c): space = "" #if hasattr(c, "bl_space_type"): # space = c.bl_space_type - + region = "" #if hasattr(c, "bl_region_type"): # region = c.bl_region_type - + label = "" if hasattr(c, "bl_label"): label = c.bl_label - + return prefix+": " + space + " " + region + " " + label def walk_module(opname, mod, calls=[], exclude=[]): - + for name, m in inspect.getmembers(mod): if inspect.ismodule(m): if m.__name__ not in exclude: @@ -94,7 +94,7 @@ def walk_module(opname, mod, calls=[], exclude=[]): if opname in s: file = mod.__file__ line = n + i - + if issubclass(m, Panel) and name != "Panel": loc = make_loc("Panel", m) calls.append([opname, loc, file, line]) @@ -121,10 +121,10 @@ def getclazz(opname): def getmodule(opname): addon = True clazz = getclazz(opname) - + if clazz is None: return "", -1, False - + modn = clazz.__module__ try: @@ -168,24 +168,24 @@ def get_ops(): return [(y, y, "", x) for x, y in enumerate(l)] class OperatorEntry(PropertyGroup): - + label : StringProperty( name="Label", description="", default="" ) - + path : StringProperty( name="Path", description="", default="" ) - + line : IntProperty( name="Line", description="", default=-1 - ) + ) class TEXT_OT_EditOperator(Operator): bl_idname = "text.edit_operator" @@ -200,22 +200,22 @@ class TEXT_OT_EditOperator(Operator): description="", items=items ) - + path : StringProperty( name="Path", description="", default="" ) - + line : IntProperty( name="Line", description="", default=-1 ) - + def show_text(self, context, path, line): found = False - + for t in bpy.data.texts: if t.filepath == path: #switch to the wanted text first @@ -231,25 +231,25 @@ class TEXT_OT_EditOperator(Operator): "Opened file: " + path) bpy.ops.text.open(filepath=path) bpy.ops.text.jump(line=line) - + def show_calls(self, context): import bl_ui import addon_utils - + exclude = stdlib_excludes() exclude.append("bpy") exclude.append("sys") - + calls = [] walk_module(self.op, bl_ui, calls, exclude) - + for m in addon_utils.modules(): try: mod = sys.modules[m.__name__] walk_module(self.op, mod, calls, exclude) except KeyError: continue - + for c in calls: cl = context.scene.calls.add() cl.name = c[0] @@ -265,33 +265,33 @@ class TEXT_OT_EditOperator(Operator): if self.path != "" and self.line != -1: #invocation of one of the "found" locations self.show_text(context, self.path, self.line) - return {'FINISHED'} + return {'FINISHED'} else: context.scene.calls.clear() path, line, addon = getmodule(self.op) - + if addon: self.show_text(context, path, line) - + #add convenient "source" button, to toggle back from calls to source c = context.scene.calls.add() c.name = self.op c.label = "Source" c.path = path c.line = line - + self.show_calls(context) context.area.tag_redraw() - + return {'FINISHED'} else: - + self.report({'WARNING'}, "Found no source file for " + self.op) - + self.show_calls(context) context.area.tag_redraw() - + return {'FINISHED'} @@ -307,7 +307,7 @@ class TEXT_PT_EditOperatorPanel(Panel): op = layout.operator("text.edit_operator") op.path = "" op.line = -1 - + if len(context.scene.calls) > 0: box = layout.box() box.label(text="Calls of: " + context.scene.calls[0].name) @@ -321,7 +321,7 @@ class TEXT_PT_EditOperatorPanel(Panel): def register(): bpy.utils.register_class(OperatorEntry) - bpy.types.Scene.calls = bpy.props.CollectionProperty(name="Calls", + bpy.types.Scene.calls = bpy.props.CollectionProperty(name="Calls", type=OperatorEntry) bpy.utils.register_class(TEXT_OT_EditOperator) bpy.utils.register_class(TEXT_PT_EditOperatorPanel) diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py index 160b0043e7401725fa37e08021c839397ad7b3a7..f3cd767159af2c308bad203cfa4703a0cd65f16d 100644 --- a/io_coat3D/__init__.py +++ b/io_coat3D/__init__.py @@ -850,10 +850,10 @@ class SCENE_OT_import(bpy.types.Operator): if(scene_objects.coat3D.applink_address == new_applink_address): new_object = False - + elif(os.path.isfile(exportfile3)): obj_pathh = open(exportfile3) - + for line in obj_pathh: new_applink_address = line break @@ -865,7 +865,7 @@ class SCENE_OT_import(bpy.types.Operator): scene_objects.coat3D.type == '' new_ref_object = True nimi = scene_objects.name - + exportfile = coat3D.exchangedir @@ -873,7 +873,7 @@ class SCENE_OT_import(bpy.types.Operator): exportfile += ('%sexport.txt' % (os.sep)) if (os.path.isfile(exportfile)): os.remove(exportfile) - + if(new_ref_object): create_collection = True @@ -899,7 +899,7 @@ class SCENE_OT_import(bpy.types.Operator): old_objects = bpy.data.objects.keys() object_list = [] - + bpy.ops.import_scene.fbx(filepath=new_applink_address, global_scale = 0.01,axis_forward='X', axis_up='Y',use_custom_normals=False) new_objects = bpy.data.objects.keys() diff_objects = [i for i in new_objects if i not in old_objects] @@ -909,12 +909,12 @@ class SCENE_OT_import(bpy.types.Operator): refmesh = bpy.data.objects[nimi] copymesh = bpy.data.objects[nimi].copy() - + copymesh.data = bpy.data.objects[diff_object].data copymesh.coat3D.applink_name = bpy.data.objects[diff_object].data.name copymesh.coat3D.applink_address = refmesh.coat3D.applink_address ne_name = bpy.data.objects[diff_object].data.name - + copymesh.coat3D.type = 'ppp' copymesh.coat3D.retopo = True @@ -931,7 +931,7 @@ class SCENE_OT_import(bpy.types.Operator): copymesh.material_slots[0].material.node_tree.nodes['Principled BSDF'].inputs['Metallic'].default_value = 0 copymesh.material_slots[0].material.node_tree.nodes['Principled BSDF'].inputs['Specular'].default_value = 0.5 - + refmesh.coat3D.applink_name = '' refmesh.coat3D.applink_address = '' refmesh.coat3D.type = '' @@ -998,7 +998,7 @@ class SCENE_OT_import(bpy.types.Operator): path3b_n = coat3D.exchangedir path3b_n += ('%slast_saved_3b_file.txt' % (os.sep)) if(objekti.coat3D.import_mesh and coat3D.importmesh == True): - + objekti.coat3D.import_mesh = False objekti.select_set(True) @@ -1007,7 +1007,7 @@ class SCENE_OT_import(bpy.types.Operator): '''Changes objects mesh into proxy mesh''' if(objekti.coat3D.type != 'ref'): - + for proxy_objects in diff_objects: if(objekti.coat3D.retopo == False): if (proxy_objects == objekti.coat3D.applink_name): @@ -1151,7 +1151,7 @@ class SCENE_OT_import(bpy.types.Operator): objekti.coat3D.applink_name = objekti.name objekti.coat3D.applink_mesh = True objekti.coat3D.import_mesh = False - + bpy.ops.object.transforms_to_deltas(mode='SCALE') objekti.coat3D.applink_firsttime = False bpy.context.collection.all_objects[del_obj].select_set(False) diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index 9e2f48ab7e83514ac3da20dde7f7db2494b2c414..1b72888fc41f6bf8a52e219ddf462da4e99e558f 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -565,12 +565,12 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, tile_int_x = int(tile[3]) tile_int_y = int(tile[2]) - + min_node = texture_tree.nodes.new('ShaderNodeVectorMath') min_node.operation = "MINIMUM" min_node.inputs[1].default_value[0] = tile_int_x - 1 min_node.inputs[1].default_value[1] = tile_int_y - + max_node = texture_tree.nodes.new('ShaderNodeVectorMath') max_node.operation = "MAXIMUM" max_node.inputs[1].default_value[0] = tile_int_x diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py index 013b5bc5b854c3ed764b9d791495008a15fa3898..ceb2442074b85c8c032968a527012f49389c25f3 100644 --- a/io_curve_svg/import_svg.py +++ b/io_curve_svg/import_svg.py @@ -1741,30 +1741,30 @@ class SVGGeometrySVG(SVGGeometryContainer): matrix = self.getNodeMatrix() # Better SVG compatibility: match svg-document units - # with blender units - + # with blender units + viewbox = [] unit = '' - + if self._node.getAttribute('height'): raw_height = self._node.getAttribute('height') token, last_char = read_float(raw_height) document_height = float(token) - unit = raw_height[last_char:].strip() - + unit = raw_height[last_char:].strip() + if self._node.getAttribute('viewBox'): viewbox = parse_array_of_floats(self._node.getAttribute('viewBox')) - + if len(viewbox) == 4 and unit in ('cm', 'mm', 'in', 'pt', 'pc'): - #convert units to BU: - unitscale = units[unit] / 90 * 1000 / 39.3701 - - #apply blender unit scale: + #convert units to BU: + unitscale = units[unit] / 90 * 1000 / 39.3701 + + #apply blender unit scale: unitscale = unitscale / bpy.context.scene.unit_settings.scale_length - + matrix = matrix @ Matrix.Scale(unitscale, 4, Vector((1.0, 0.0, 0.0))) - matrix = matrix @ Matrix.Scale(unitscale, 4, Vector((0.0, 1.0, 0.0))) + matrix = matrix @ Matrix.Scale(unitscale, 4, Vector((0.0, 1.0, 0.0))) # match document origin with 3D space origin. if self._node.getAttribute('viewBox'): diff --git a/io_export_dxf/__init__.py b/io_export_dxf/__init__.py index ed5b33a99cd1c9f7c004a15cdca4318f0a1b969a..cb0f13228cb4f21b5ba31e70fa4d930a83ad5bb3 100644 --- a/io_export_dxf/__init__.py +++ b/io_export_dxf/__init__.py @@ -56,6 +56,6 @@ def unregister(): for cls in reversed(classes): unregister_class(cls) bpy.types.TOPBAR_MT_file_export.remove(menu_func) - + if __name__ == "__main__": register() diff --git a/io_export_dxf/export_dxf.py b/io_export_dxf/export_dxf.py index 66913b6a83ef9d5755be883b9489c352a29e4dd5..88a27b3b95a059ee0884d6e3dbe19185e7937f6a 100644 --- a/io_export_dxf/export_dxf.py +++ b/io_export_dxf/export_dxf.py @@ -41,7 +41,7 @@ def exportDXF(context, filePath, settings): print("Generating Object list for export... (Root parents only)") scene = context.scene - + if settings['onlySelected'] is True: objects = (ob for ob in scene.objects if not ob.hide_viewport and ob.select_get() and ob.type in SUPPORTED_TYPES) else: diff --git a/io_export_dxf/primitive_exporters/mesh_exporter.py b/io_export_dxf/primitive_exporters/mesh_exporter.py index bffc4139a8310eacd3721bb502aaa61c271f5383..225c60d841f892a4a69dc362cec931cf4b8323ed 100644 --- a/io_export_dxf/primitive_exporters/mesh_exporter.py +++ b/io_export_dxf/primitive_exporters/mesh_exporter.py @@ -69,7 +69,7 @@ class MeshDXFExporter(BasePrimitiveDXFExporter): allpoints = self.toGlobalOrigin(allpoints) faces=[] edges=[] - + me.calc_loop_triangles() #me.update(calc_tessface=True) me_faces = me.loop_triangles #tessfaces #print('deb: allpoints=\n', allpoints) #--------- diff --git a/io_export_paper_model.py b/io_export_paper_model.py index 1b7a399485b135c66b080b6ab472985eca1ae9da..083c13d4b93734a3bc4efb167c74902424c819af 100644 --- a/io_export_paper_model.py +++ b/io_export_paper_model.py @@ -185,7 +185,7 @@ class Unfolder: bm = bmesh.from_edit_mesh(ob.data) self.mesh = Mesh(bm, ob.matrix_world) self.mesh.check_correct() - + def __del__(self): if not self.do_create_uvmap: self.mesh.delete_uvmap() @@ -264,7 +264,7 @@ class Unfolder: bk.use_pass_direct, bk.use_pass_indirect, bk.use_pass_color = False, False, True sce.cycles.samples = 1 else: - sce.cycles.samples = properties.bake_samples + sce.cycles.samples = properties.bake_samples if sce.cycles.bake_type == 'COMBINED': bk.use_pass_direct, bk.use_pass_indirect = True, True bk.use_pass_diffuse, bk.use_pass_glossy, bk.use_pass_transmission, bk.use_pass_subsurface, bk.use_pass_ambient_occlusion, bk.use_pass_emit = True, False, False, True, True, True @@ -302,10 +302,10 @@ class Mesh: if edge.main_faces: edge.calculate_angle() self.copy_freestyle_marks() - + def delete_uvmap(self): self.data.loops.layers.uv.remove(self.looptex) if self.looptex else None - + def copy_freestyle_marks(self): # NOTE: this is a workaround for NotImplementedError on bmesh.edges.layers.freestyle mesh = bpy.data.meshes.new("unfolder_temp") @@ -313,7 +313,7 @@ class Mesh: for bmedge, edge in self.edges.items(): edge.freestyle = mesh.edges[bmedge.index].use_freestyle_mark bpy.data.meshes.remove(mesh) - + def mark_cuts(self): for bmedge, edge in self.edges.items(): if edge.is_main_cut and not bmedge.is_boundary: @@ -329,7 +329,7 @@ class Mesh: diameter = max((center - vertex.co).length for vertex in face.verts) threshold = 0.01 * diameter return any(abs(v.co.dot(face.normal) - plane_d) > threshold for v in face.verts) - + null_edges = {e for e in self.edges.keys() if e.calc_length() < epsilon and e.link_faces} null_faces = {f for f in self.data.faces if f.calc_area() < epsilon} twisted_faces = {f for f in self.data.faces if is_twisted(f)} @@ -452,7 +452,7 @@ class Mesh: def add_sticker(uvedge, index, target_uvedge): uvedge.sticker = Sticker(uvedge, default_width, index, target_uvedge) uvedge.uvface.island.add_marker(uvedge.sticker) - + def is_index_obvious(uvedge, target): if uvedge in (target.neighbor_left, target.neighbor_right): return True @@ -632,7 +632,7 @@ class Mesh: island.image_path = image_path image.user_clear() bpy.data.images.remove(image) - + def bake(self, faces, image): if not self.looptex: raise UnfoldError("The mesh has no UV Map slots left. Either delete a UV Map or export the net without textures.") @@ -766,14 +766,14 @@ class Island: self.is_inside_out = False # swaps concave <-> convex edges self.has_safe_geometry = True self.sticker_numbering = 0 - + uvface = UVFace(face, self, matrix, normal_matrix) self.vertices.update(uvface.vertices) self.edges.update(uvface.edges) self.faces[face] = uvface # UVEdges on the boundary self.boundary = list(self.edges.values()) - + def add_marker(self, marker): self.fake_vertices.extend(marker.bounds) self.markers.append(marker) @@ -2050,7 +2050,7 @@ class ExportPaperModel(bpy.types.Operator): @classmethod def poll(cls, context): return context.active_object and context.active_object.type == 'MESH' - + def prepare(self, context): sce = context.scene self.recall_mode = context.object.mode @@ -2062,7 +2062,7 @@ class ExportPaperModel(bpy.types.Operator): self.unfolder.prepare(cage_size, scale=sce.unit_settings.scale_length/self.scale, limit_by_page=sce.paper_model.limit_by_page) if self.scale == 1: self.scale = ceil(self.get_scale_ratio(sce)) - + def recall(self): if self.unfolder: del self.unfolder @@ -2225,7 +2225,7 @@ class SelectIsland(bpy.types.Operator): bl_idname = "mesh.select_paper_island" bl_label = "Select Island" bl_description = "Select an island of the paper model net" - + operation: bpy.props.EnumProperty( name="Operation", description="Operation with the current selection", default='ADD', items=[ diff --git a/io_mesh_atomic/__init__.py b/io_mesh_atomic/__init__.py index f7ebcb886ca2511aadd64ed330147db383ab1160..d9e13c4718837cac696d86185e0ae8171e0ef5d3 100644 --- a/io_mesh_atomic/__init__.py +++ b/io_mesh_atomic/__init__.py @@ -33,13 +33,13 @@ # Acknowledgements # ================ # -# A big thank you to all those people who I met in particular in the IRC and +# A big thank you to all those people who I met in particular in the IRC and # who helped me a lot. # # Blender developers # ------------------ -# Campbell Barton (ideasman) -# Brendon Murphy (meta_androcto) +# Campbell Barton (ideasman) +# Brendon Murphy (meta_androcto) # Truman Melton (?) (truman) # Kilon Alios (kilon) # ?? (CoDEmanX) @@ -104,7 +104,7 @@ class AddonPreferences(AddonPreferences): default=True, description="Import/export XYZ", ) - # This boolean is checked in the poll function in PANEL_PT_prepare + # This boolean is checked in the poll function in PANEL_PT_prepare # (see utility.py). bool_utility : BoolProperty( name="Utility panel", @@ -119,7 +119,7 @@ class AddonPreferences(AddonPreferences): layout.prop(self, "bool_pdb") layout.prop(self, "bool_xyz") layout.prop(self, "bool_utility") - + # ----------------------------------------------------------------------------- # Menu @@ -149,7 +149,7 @@ def menu_func_export_xyz(self, context): def register(): from bpy.utils import register_class - + register_class(AddonPreferences) register_class(pdb_gui.IMPORT_OT_pdb) @@ -162,21 +162,21 @@ def register(): bpy.types.TOPBAR_MT_file_import.append(menu_func_import_xyz) bpy.types.TOPBAR_MT_file_export.append(menu_func_export_xyz) - classes = (utility_gui.PANEL_PT_prepare, + classes = (utility_gui.PANEL_PT_prepare, utility_gui.PanelProperties, - utility_gui.DatafileApply, - utility_gui.DefaultAtom, - utility_gui.ReplaceAtom, - utility_gui.SeparateAtom, - utility_gui.DistanceButton, - utility_gui.RadiusAllBiggerButton, - utility_gui.RadiusAllSmallerButton, - utility_gui.SticksAllBiggerButton, + utility_gui.DatafileApply, + utility_gui.DefaultAtom, + utility_gui.ReplaceAtom, + utility_gui.SeparateAtom, + utility_gui.DistanceButton, + utility_gui.RadiusAllBiggerButton, + utility_gui.RadiusAllSmallerButton, + utility_gui.SticksAllBiggerButton, utility_gui.SticksAllSmallerButton) from bpy.utils import register_class utility_panel.read_elements() for cls in classes: - register_class(cls) + register_class(cls) scene = bpy.types.Scene scene.atom_blend = bpy.props.PointerProperty(type=utility_gui.PanelProperties) @@ -197,19 +197,19 @@ def unregister(): bpy.types.TOPBAR_MT_file_import.remove(menu_func_import_xyz) bpy.types.TOPBAR_MT_file_export.remove(menu_func_export_xyz) - classes = (utility_gui.PANEL_PT_prepare, + classes = (utility_gui.PANEL_PT_prepare, utility_gui.PanelProperties, - utility_gui.DatafileApply, - utility_gui.DefaultAtom, - utility_gui.ReplaceAtom, - utility_gui.SeparateAtom, - utility_gui.DistanceButton, - utility_gui.RadiusAllBiggerButton, - utility_gui.RadiusAllSmallerButton, - utility_gui.SticksAllBiggerButton, + utility_gui.DatafileApply, + utility_gui.DefaultAtom, + utility_gui.ReplaceAtom, + utility_gui.SeparateAtom, + utility_gui.DistanceButton, + utility_gui.RadiusAllBiggerButton, + utility_gui.RadiusAllSmallerButton, + utility_gui.SticksAllBiggerButton, utility_gui.SticksAllSmallerButton) for cls in classes: - unregister_class(cls) + unregister_class(cls) # ----------------------------------------------------------------------------- diff --git a/io_mesh_atomic/utility_gui.py b/io_mesh_atomic/utility_gui.py index 27f283b1bf6d7a14455074c5d93c2e38b87a121f..97395036f99c6c894efcfab86a2210ea63b57e1c 100644 --- a/io_mesh_atomic/utility_gui.py +++ b/io_mesh_atomic/utility_gui.py @@ -22,7 +22,7 @@ from bpy.props import (StringProperty, EnumProperty, FloatProperty, BoolProperty) - + from io_mesh_atomic.utility_panel import choose_objects from io_mesh_atomic.utility_panel import custom_datafile from io_mesh_atomic.utility_panel import custom_datafile_change_atom_props @@ -43,7 +43,7 @@ class PANEL_PT_prepare(Panel): bl_idname = "ATOMIC_PT_utilities" - # This thing here just guarantees that the panel is NOT opened when the + # This thing here just guarantees that the panel is NOT opened when the # check box in the addon preferences is not activated! See __init__.py @classmethod def poll(cls, context): @@ -66,7 +66,7 @@ class PANEL_PT_prepare(Panel): col.operator("atom_blend.button_distance") col.prop(scn, "distance") - # This is from Blender 2.79 and does not work in 2.80. However, it + # This is from Blender 2.79 and does not work in 2.80. However, it # might be useful later on if changed. # #box = layout.box() diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py index 77c7fe55ad3226a9014f28c54573f8c11c765f34..3b2c00551e9a15e3735136f05799a828acd81e9e 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_materials_pbr_metallic_roughness.py @@ -103,7 +103,7 @@ def __gather_base_color_texture(blender_material, export_settings): inputs = (base_color_socket, alpha_socket, ) else: inputs = (base_color_socket,) - + return gltf2_blender_gather_texture_info.gather_texture_info(inputs, export_settings) diff --git a/magic_uv/lib/bglx.py b/magic_uv/lib/bglx.py index 5abde12cd905f0fa004fdf8c250128c97458f2ce..24200caf12cdf29cb12be537e7bd4c8ec21e198f 100644 --- a/magic_uv/lib/bglx.py +++ b/magic_uv/lib/bglx.py @@ -116,11 +116,11 @@ def _get_transparency_shader(): vertex_shader = ''' uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + in vec2 pos; in vec2 texCoord; out vec2 uvInterp; - + void main() { uvInterp = texCoord; @@ -132,10 +132,10 @@ def _get_transparency_shader(): fragment_shader = ''' uniform sampler2D image; uniform vec4 color; - + in vec2 uvInterp; out vec4 fragColor; - + void main() { fragColor = texture(image, uvInterp); diff --git a/mesh_auto_mirror.py b/mesh_auto_mirror.py index 9585ee96ee5446a3f7e97b8b3bf79f3fba8715b1..c32d542609908c92be8776f894e40ef7a4250b85 100644 --- a/mesh_auto_mirror.py +++ b/mesh_auto_mirror.py @@ -61,7 +61,7 @@ class AlignVertices(Operator): def execute(self, context): automirror = context.scene.automirror - + bpy.ops.object.mode_set(mode = 'OBJECT') x1,y1,z1 = bpy.context.scene.cursor.location @@ -142,7 +142,7 @@ class AutoMirror(bpy.types.Operator): automirror = context.scene.automirror X,Y,Z = 0,0,0 - + if automirror.axis == 'x': X = 1 elif automirror.axis == 'y': @@ -154,14 +154,14 @@ class AutoMirror(bpy.types.Operator): if bpy.context.object.mode != "EDIT": bpy.ops.object.mode_set(mode = "EDIT") # Go to edit mode - + bpy.ops.mesh.select_all(action = 'SELECT') # Select all the vertices - + if automirror.orientation == 'positive': orientation = 1 else: orientation = -1 - + cut_normal = self.get_local_axis_vector(context, X, Y, Z, orientation) # Cut the mesh @@ -213,7 +213,7 @@ class VIEW3D_PT_BisectMirror(Panel): def draw(self, context): automirror = context.scene.automirror - + layout = self.layout col = layout.column(align=True) @@ -266,7 +266,7 @@ class AutoMirrorProps(PropertyGroup): clipping : BoolProperty( default=True, ) - + Use_Matcap : BoolProperty( default=True, description="Use clipping for the mirror modifier", @@ -340,7 +340,7 @@ classes = ( def register(): for cls in classes: bpy.utils.register_class(cls) - + bpy.types.Scene.automirror = PointerProperty(type = AutoMirrorProps) update_panel(None, bpy.context) @@ -348,7 +348,7 @@ def register(): def unregister(): for cls in reversed(classes): bpy.utils.unregister_class(cls) - + del bpy.types.Scene.automirror if __name__ == "__main__": diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 68f921cca85746ea83f87b6636e0b8550adf59b8..ee6349b6b7c2745786ec5d1c3d7c4557fff7a81a 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -317,7 +317,7 @@ class MESH_OT_SURFSK_add_surface(Operator): ) strokes_type: StringProperty() initial_global_undo_state: BoolProperty() - + def draw(self, context): layout = self.layout @@ -3089,14 +3089,14 @@ class MESH_OT_SURFSK_add_surface(Operator): except: pass - try: + try: global global_in_front self.main_object.show_in_front = global_in_front bpy.context.scene.bsurfaces.SURFSK_in_front = global_in_front except: pass - try: + try: global global_show_wire self.main_object.show_wire = global_show_wire bpy.context.scene.bsurfaces.SURFSK_show_wire = global_show_wire @@ -3188,7 +3188,7 @@ class MESH_OT_SURFSK_add_surface(Operator): if global_shade_smooth: bpy.ops.object.shade_smooth() else: - bpy.ops.object.shade_flat() + bpy.ops.object.shade_flat() # Delete main splines bpy.ops.object.mode_set('INVOKE_REGION_WIN', mode='OBJECT') @@ -4318,7 +4318,7 @@ def conver_gpencil_to_curve(self, context, pencil, type): if not error: for i, _stroke in enumerate(strokes): stroke_points = strokes[i].points - data_list = [ (point.co.x, point.co.y, point.co.z) + data_list = [ (point.co.x, point.co.y, point.co.z) for point in stroke_points ] points_to_add = len(data_list)-1 diff --git a/mesh_looptools.py b/mesh_looptools.py index 62d3b9bed1b364d6f7084ae67b4bc147c025babe..1247593a9f1b81b8bc15ff75faaf1fc3de400754 100644 --- a/mesh_looptools.py +++ b/mesh_looptools.py @@ -3867,7 +3867,7 @@ class RemoveAnnotation(Operator): return {'CANCELLED'} return{'FINISHED'} - + # GPencil operator class RemoveGPencil(Operator): bl_idname = "remove.gp" @@ -3997,7 +3997,7 @@ class GStretch(Operator): looptools = context.window_manager.looptools layout = self.layout col = layout.column() - + col.prop(self, "method") col.separator() @@ -4373,7 +4373,7 @@ class Space(Operator): if derived: bm_mod.free() terminate() - + cache_delete("Space") return{'FINISHED'} diff --git a/mesh_tiny_cad/E2F.py b/mesh_tiny_cad/E2F.py index 25f17e9f24890eec2335cdbd15e9d8d154e27b09..70b51298768819f7dfb66f2614735a703e7b0ec6 100644 --- a/mesh_tiny_cad/E2F.py +++ b/mesh_tiny_cad/E2F.py @@ -29,9 +29,9 @@ def failure_message(self): def failure_message_on_plane(self): msg2 = """\ -Edge2Face expects the edge to intersect at one point on the plane of the selected face. You're -seeing this warning because mathutils.geometry.intersect_line_plane is being called on an edge/face -combination that has no clear intersection point ( both points of the edge either touch the same +Edge2Face expects the edge to intersect at one point on the plane of the selected face. You're +seeing this warning because mathutils.geometry.intersect_line_plane is being called on an edge/face +combination that has no clear intersection point ( both points of the edge either touch the same plane as the face or they lie in a plane that is offset along the face's normal )""" lines = msg2.split('\n') for line in lines: diff --git a/mesh_tools/__init__.py b/mesh_tools/__init__.py index 9a1147b69593710bde79e5219f1e560d6640faf9..f87b4057b03c2ce17eae23ac309f30dc4197f7de 100644 --- a/mesh_tools/__init__.py +++ b/mesh_tools/__init__.py @@ -707,7 +707,7 @@ class MESH_OT_face_inset_fillet(Operator): edit_mode_in() return {'FINISHED'} - + # ********** Edit Multiselect ********** class VIEW3D_MT_Edit_MultiMET(Menu): bl_label = "Multi Select" @@ -897,7 +897,7 @@ class VIEW3D_MT_edit_mesh_tools(Menu): text="Multi Extrude") layout.operator('mesh.split_solidify', text="Split Solidify") - + # panel containing all tools class VIEW3D_PT_edit_mesh_tools(Panel): @@ -1017,7 +1017,7 @@ class VIEW3D_PT_edit_mesh_tools(Panel): row.operator("mesh.tris_convert_to_quads") row = col_top.row(align=True) row.operator("mesh.relax") - + # property group containing all properties for the gui in the panel class EditToolsProps(PropertyGroup): """ diff --git a/mesh_tools/mesh_edge_roundifier.py b/mesh_tools/mesh_edge_roundifier.py index 704a260d3c5682f09475431dbdceb7487bf6bae3..2d7ed3d307cfc1e8a0c2ab66f29788dddc6c5472 100644 --- a/mesh_tools/mesh_edge_roundifier.py +++ b/mesh_tools/mesh_edge_roundifier.py @@ -1371,12 +1371,12 @@ class EdgeRoundifier(Operator): @classmethod def poll(cls, context): return (context.view_layer.objects.active.type == 'MESH') and (context.view_layer.objects.active.mode == 'EDIT') - + def draw_item(self, context): self.layout.operator_context = 'INVOKE_DEFAULT' self.layout.operator('mesh.edge_roundifier') - + classes = ( EdgeRoundifier, ) diff --git a/mesh_tools/mesh_offset_edges.py b/mesh_tools/mesh_offset_edges.py index 524076a5b808d075d20483e135d7da9245c5362b..5372cb3049cd9be7a876c592f57d5404a7c85f08 100644 --- a/mesh_tools/mesh_offset_edges.py +++ b/mesh_tools/mesh_offset_edges.py @@ -573,7 +573,7 @@ class OffsetEdges(bpy.types.Operator): row.prop(self, d_mode) row.prop(self, flip, icon='ARROW_LEFTRIGHT', icon_only=True) if self.depth_mode == 'angle': - layout.prop(self, 'angle_presets', text="Presets", expand=True) + layout.prop(self, 'angle_presets', text="Presets", expand=True) layout.separator() @@ -769,7 +769,7 @@ class OffsetEdgesMenu(bpy.types.Menu): classes = ( OffsetEdges, OffsetEdgesMenu, -) +) def draw_item(self, context): self.layout.menu("VIEW3D_MT_edit_mesh_offset_edges") diff --git a/node_arrange.py b/node_arrange.py index ade86b1f23684ef5dc727355dfad5ebf85702c78..c9c91cda991fac8ab9420edcc9089f993d197ed7 100644 --- a/node_arrange.py +++ b/node_arrange.py @@ -229,14 +229,14 @@ def nodemargin(self, context): for i in ntree.nodes: if i.type == 'GROUP': n_groups.append(i) - + while n_groups: j = n_groups.pop(0) nodes_iterate(j.node_tree) for i in j.node_tree.nodes: if i.type == 'GROUP': n_groups.append(i) - + nodes_iterate(ntree) # arrange nodes + this center nodes together diff --git a/object_edit_linked.py b/object_edit_linked.py index 01184dbbb90ee1d6912af6fbcb73009286112b42..e4428e14f06d7bd8cfa320fdd63961f4e724faa5 100644 --- a/object_edit_linked.py +++ b/object_edit_linked.py @@ -262,7 +262,7 @@ classes = ( def register(): - bpy.app.handlers.load_post.append(linked_file_check) + bpy.app.handlers.load_post.append(linked_file_check) for c in classes: bpy.utils.register_class(c) @@ -278,15 +278,15 @@ def register(): default=False) # add the function to the file menu - bpy.types.TOPBAR_MT_file_external_data.append(TOPBAR_MT_edit_linked_submenu.draw) + bpy.types.TOPBAR_MT_file_external_data.append(TOPBAR_MT_edit_linked_submenu.draw) def unregister(): - bpy.app.handlers.load_post.remove(linked_file_check) - bpy.types.TOPBAR_MT_file_external_data.remove(TOPBAR_MT_edit_linked_submenu) + bpy.app.handlers.load_post.remove(linked_file_check) + bpy.types.TOPBAR_MT_file_external_data.remove(TOPBAR_MT_edit_linked_submenu) del bpy.types.Scene.use_autosave del bpy.types.Scene.use_instance diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py index 22fcc1d398b22aa3f6d73048fe434348b27ca197..93eacd551495b98707ac8f945cdf0772d67d245e 100644 --- a/oscurart_tools/__init__.py +++ b/oscurart_tools/__init__.py @@ -29,7 +29,7 @@ bl_info = { "wiki_url": "https://www.oscurart.com.ar", "category": "Object", } - + import bpy from bpy.app.handlers import persistent @@ -67,16 +67,16 @@ from bpy.props import ( # mesh class VIEW3D_MT_edit_mesh_oscurarttools(Menu): - bl_label = "OscurartTools" - + bl_label = "OscurartTools" + def draw(self, context): layout = self.layout - + layout.operator("mesh.uv_island_copy") layout.operator("mesh.uv_island_paste") layout.operator("mesh.select_doubles") - layout.separator() - layout.operator("image.reload_images_osc") + layout.separator() + layout.operator("image.reload_images_osc") layout.operator("file.save_incremental_backup") layout.operator("file.collect_all_images") layout.operator("file.create_batch_maker_osc") @@ -87,17 +87,17 @@ def menu_funcMesh(self, context): # image class IMAGE_MT_uvs_oscurarttools(Menu): - bl_label = "OscurartTools" - + bl_label = "OscurartTools" + def draw(self, context): layout = self.layout - + layout.operator("mesh.uv_island_copy") layout.operator("mesh.uv_island_paste") layout.operator("mesh.overlap_uv_faces") - layout.operator("mesh.select_flipped_uvs") - layout.separator() - layout.operator("image.reload_images_osc") + layout.operator("mesh.select_flipped_uvs") + layout.separator() + layout.operator("image.reload_images_osc") layout.operator("file.save_incremental_backup") layout.operator("file.collect_all_images") layout.operator("file.create_batch_maker_osc") @@ -110,19 +110,19 @@ def menu_funcImage(self, context): # object class VIEW3D_MT_object_oscurarttools(Menu): - bl_label = "OscurartTools" - + bl_label = "OscurartTools" + def draw(self, context): layout = self.layout - - layout.operator("mesh.vertex_color_mask") + + layout.operator("mesh.vertex_color_mask") layout.operator("object.distribute_osc") layout.operator("mesh.remove_modifiers") layout.operator("object.search_and_select_osc") layout.operator("object.shape_key_to_objects_osc") - layout.operator("mesh.apply_linked_meshes") - layout.separator() - layout.operator("image.reload_images_osc") + layout.operator("mesh.apply_linked_meshes") + layout.separator() + layout.operator("image.reload_images_osc") layout.operator("file.save_incremental_backup") layout.operator("file.collect_all_images") layout.operator("file.create_batch_maker_osc") @@ -138,8 +138,8 @@ classes = ( VIEW3D_MT_edit_mesh_oscurarttools, IMAGE_MT_uvs_oscurarttools, VIEW3D_MT_object_oscurarttools, - reload_images.reloadImages, - overlap_uvs.CopyUvIsland, + reload_images.reloadImages, + overlap_uvs.CopyUvIsland, overlap_uvs.PasteUvIsland, distribute.DistributeOsc, selection.OSSELECTION_HT_OscSelection, @@ -163,23 +163,23 @@ classes = ( flipped_uvs.selectFlippedUvs ) -def register(): +def register(): from bpy.types import Scene Scene.multimeshedit = StringProperty() bpy.types.VIEW3D_MT_edit_mesh_context_menu.prepend(menu_funcMesh) bpy.types.IMAGE_MT_uvs_context_menu.prepend(menu_funcImage) bpy.types.VIEW3D_MT_object_context_menu.prepend(menu_funcObject) bpy.app.handlers.render_init.append(render_tokens.replaceTokens) - bpy.app.handlers.render_cancel.append(render_tokens.restoreTokens) - bpy.app.handlers.render_complete.append(render_tokens.restoreTokens) - bpy.app.handlers.render_pre.append(material_overrides.ApplyOverrides) - bpy.app.handlers.render_cancel.append(material_overrides.RestoreOverrides) - bpy.app.handlers.render_post.append(material_overrides.RestoreOverrides) - + bpy.app.handlers.render_cancel.append(render_tokens.restoreTokens) + bpy.app.handlers.render_complete.append(render_tokens.restoreTokens) + bpy.app.handlers.render_pre.append(material_overrides.ApplyOverrides) + bpy.app.handlers.render_cancel.append(material_overrides.RestoreOverrides) + bpy.app.handlers.render_post.append(material_overrides.RestoreOverrides) + from bpy.utils import register_class for cls in classes: - register_class(cls) - + register_class(cls) + def unregister(): bpy.types.VIEW3D_MT_edit_mesh_context_menu.remove(menu_funcMesh) diff --git a/oscurart_tools/files/save_incremental.py b/oscurart_tools/files/save_incremental.py index d655b08e9b02df8a34f8ed26238bb415c0e7ddc0..b10db327d93bbf2a1ef34cfddb91fcd2ce12949d 100644 --- a/oscurart_tools/files/save_incremental.py +++ b/oscurart_tools/files/save_incremental.py @@ -26,34 +26,34 @@ import os def saveBkp (self, context): fileFolder = os.path.dirname(bpy.data.filepath) versionFolder = os.path.join(fileFolder,"VERSIONS") - + #creo folder if os.path.exists(versionFolder): print("existe") else: - os.mkdir(versionFolder) - + os.mkdir(versionFolder) + #sin version a versionada - if not bpy.data.filepath.count("_v"): - filelist = [file for file in os.listdir(versionFolder) if file.count("_v") and not file.count("blend1")] + if not bpy.data.filepath.count("_v"): + filelist = [file for file in os.listdir(versionFolder) if file.count("_v") and not file.count("blend1")] filelower = 0 print(filelist) for file in filelist: if int(file.split(".")[0][-2:]) > filelower: - filelower = int(file.split(".")[0][-2:]) + filelower = int(file.split(".")[0][-2:]) - savepath = "%s/VERSIONS/%s_v%02d.blend" % (os.path.dirname(bpy.data.filepath),bpy.path.basename(bpy.data.filepath).split('.')[0],filelower+1) - print("Copia versionada guardada.") + savepath = "%s/VERSIONS/%s_v%02d.blend" % (os.path.dirname(bpy.data.filepath),bpy.path.basename(bpy.data.filepath).split('.')[0],filelower+1) + print("Copia versionada guardada.") bpy.ops.wm.save_as_mainfile() - bpy.ops.wm.save_as_mainfile(filepath=savepath, copy=True) + bpy.ops.wm.save_as_mainfile(filepath=savepath, copy=True) - else: + else: #versionada a sin version if bpy.data.filepath.count("_v"): filename = "%s/../%s.blend" % (os.path.dirname(bpy.data.filepath),os.path.basename(bpy.data.filepath).rpartition(".")[0].rpartition("_")[0]) print(filename) - bpy.ops.wm.save_as_mainfile(filepath=filename, copy=True) + bpy.ops.wm.save_as_mainfile(filepath=filename, copy=True) print("Copia sin version guardada.") @@ -66,5 +66,5 @@ class saveIncrementalBackup (bpy.types.Operator): def execute(self, context): saveBkp(self, context) return {'FINISHED'} - + diff --git a/oscurart_tools/mesh/apply_linked_meshes.py b/oscurart_tools/mesh/apply_linked_meshes.py index 7615c426b27bcf458979c1474c8b766a0622cff5..0bd7bf47df605eaaba3d65fcec2620047fa941e6 100644 --- a/oscurart_tools/mesh/apply_linked_meshes.py +++ b/oscurart_tools/mesh/apply_linked_meshes.py @@ -35,7 +35,7 @@ def applyLRTEx(self, context): actObj.rotation_euler = (0,0,0) actObj.scale = (1,1,1) - for ob in linkedObjects: + for ob in linkedObjects: ob.matrix_world = ob.matrix_world @ actObj.matrix_world.inverted() @@ -53,8 +53,8 @@ class ApplyLRT(bpy.types.Operator): def execute(self, context): applyLRTEx(self, context) return {'FINISHED'} - - + + diff --git a/oscurart_tools/mesh/flipped_uvs.py b/oscurart_tools/mesh/flipped_uvs.py index 3cafea7d120c0e26c994c2de3a7eba28f00163a9..14d1be4ce21fa03bcae8d410e255fac4864f8e39 100644 --- a/oscurart_tools/mesh/flipped_uvs.py +++ b/oscurart_tools/mesh/flipped_uvs.py @@ -25,18 +25,18 @@ import bmesh def defSelectFlippedUvs(self, context): bm = bmesh.from_edit_mesh(bpy.context.active_object.data) bpy.context.scene.tool_settings.use_uv_select_sync = True - + uvLayer = bm.loops.layers.uv.verify() - + for face in bm.faces: sum_edges = 0 - + for i in range(3): uv_A = face.loops[i][uvLayer].uv uv_B = face.loops[(i+1)%3][uvLayer].uv sum_edges += uv_B.cross(uv_A) - + if sum_edges > 0: face.select_set(True) diff --git a/oscurart_tools/mesh/vertex_color_id.py b/oscurart_tools/mesh/vertex_color_id.py index 3937366eb83e0f4f5aed9dd97c5a1efa28bc837a..2eb9790dd635d41e0610b2551134884ecd126d07 100644 --- a/oscurart_tools/mesh/vertex_color_id.py +++ b/oscurart_tools/mesh/vertex_color_id.py @@ -49,8 +49,8 @@ def vertexColorMask(self,context): for loop in face.loops: loop[color_layer] = color bpy.ops.object.mode_set(mode="VERTEX_PAINT") - - + + class createVCMask(bpy.types.Operator): bl_idname = "mesh.vertex_color_mask" bl_label = "Vertex Color Mask" diff --git a/oscurart_tools/object/search_and_select.py b/oscurart_tools/object/search_and_select.py index a576457c01a57f9fe3a8e4cdf46136c4f086fe84..707c7188c23d913f651aa9051ae94693580e5c5b 100644 --- a/oscurart_tools/object/search_and_select.py +++ b/oscurart_tools/object/search_and_select.py @@ -57,6 +57,6 @@ class SearchAndSelectOt(bpy.types.Operator): self.count = True self.end = True return context.window_manager.invoke_props_dialog(self) - + diff --git a/oscurart_tools/render/batch_maker.py b/oscurart_tools/render/batch_maker.py index 99780aecb66ab6a529801f650522ecccbb9049d4..fed15dccb79599fd4e459a8d0fabf466b1affbc6 100644 --- a/oscurart_tools/render/batch_maker.py +++ b/oscurart_tools/render/batch_maker.py @@ -32,8 +32,8 @@ def batchMaker(BIN): else: for scene in bpy.data.scenes: FILE.writelines("blender -b '%s' --scene %s --python-text Text -a \n" % (bpy.data.filepath,scene.name)) - - + + class oscBatchMaker (bpy.types.Operator): """It creates .bat(win) or .sh(unix) file, to execute and render from Console/Terminal""" diff --git a/oscurart_tools/render/material_overrides.py b/oscurart_tools/render/material_overrides.py index 35afc45c5ee83abf52021ed30d4d7e670e6106d6..5720d293300bde044680a09d58c8a8c55916ee74 100644 --- a/oscurart_tools/render/material_overrides.py +++ b/oscurart_tools/render/material_overrides.py @@ -8,31 +8,31 @@ from bpy.app.handlers import persistent @persistent def ApplyOverrides(dummy): - global obDict + global obDict for override in bpy.context.scene.ovlist: for ob in bpy.data.collections[override.grooverride].all_objects: if ob.type == "MESH": if not ob.hide_viewport and not ob.hide_render: - obDict.append([ob,[mat for mat in ob.data.materials]]) + obDict.append([ob,[mat for mat in ob.data.materials]]) for override in bpy.context.scene.ovlist: for ob in bpy.data.collections[override.grooverride].all_objects: if ob.type == "MESH": if not ob.hide_viewport and not ob.hide_render: for i,mat in enumerate(ob.data.materials): - ob.data.materials[i] = bpy.data.materials[override.matoverride] + ob.data.materials[i] = bpy.data.materials[override.matoverride] @persistent def RestoreOverrides(dummy): global obDict - + for set in obDict: for i,mat in enumerate(set[1]): set[0].data.materials[i] = mat - - obDict = [] + + obDict = [] # --------------------------------------------------- @@ -42,9 +42,9 @@ def RestoreOverrides(dummy): class OscOverridesProp(bpy.types.PropertyGroup): matoverride: bpy.props.StringProperty() grooverride: bpy.props.StringProperty() - -bpy.utils.register_class(OscOverridesProp) -bpy.types.Scene.ovlist = bpy.props.CollectionProperty(type=OscOverridesProp) + +bpy.utils.register_class(OscOverridesProp) +bpy.types.Scene.ovlist = bpy.props.CollectionProperty(type=OscOverridesProp) class OVERRIDES_PT_OscOverridesGUI(bpy.types.Panel): @@ -174,5 +174,5 @@ class OscOverridesKill(bpy.types.Operator): def execute(self, context): ovlist = context.scene.ovlist ovlist.remove(self.index) - return {'FINISHED'} + return {'FINISHED'} diff --git a/oscurart_tools/render/render_tokens.py b/oscurart_tools/render/render_tokens.py index 0d77f8d0f20469035385621bd370321fd9b47eb5..2ac8404eefe2082f60ce5d8284b186b9854eda93 100644 --- a/oscurart_tools/render/render_tokens.py +++ b/oscurart_tools/render/render_tokens.py @@ -30,9 +30,9 @@ def replaceTokens (dummy): "$File":os.path.basename(bpy.data.filepath).split(".")[0], "$ViewLayer":bpy.context.view_layer.name, "$Camera":bpy.context.scene.camera.name} - + renpath = bpy.context.scene.render.filepath - + bpy.context.scene.render.filepath = renpath.replace("$Scene",tokens["$Scene"]).replace("$File",tokens["$File"]).replace("$ViewLayer",tokens["$ViewLayer"]).replace("$Camera",tokens["$Camera"]) print(bpy.context.scene.render.filepath) diff --git a/power_sequencer/operators/swap_strips.py b/power_sequencer/operators/swap_strips.py index 945f99ffd3b74e0e698bca6fc316dfd147be8407..3eeb07c1a456105abb15a0deb1b656321031ac9b 100644 --- a/power_sequencer/operators/swap_strips.py +++ b/power_sequencer/operators/swap_strips.py @@ -14,234 +14,234 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # -import bpy -from operator import attrgetter - -from .utils.doc import doc_name, doc_idname, doc_brief, doc_description - - -class POWER_SEQUENCER_OT_swap_strips(bpy.types.Operator): - """ - *brief* Swaps the 2 strips between them - - - Places the first strip in the channel and starting frame (frame_final_start) of the second - strip, and places the second strip in the channel and starting frame (frame_final_end) of - the first strip. If there is no space for the swap, it does nothing. - """ - - doc = { - "name": doc_name(__qualname__), - "demo": "", - "description": doc_description(__doc__), - "shortcuts": [], - "keymap": "Sequencer", - } - bl_idname = doc_idname(__qualname__) - bl_label = doc["name"] - bl_description = doc_brief(doc["description"]) - bl_options = {"REGISTER", "UNDO"} - - direction: bpy.props.EnumProperty( - name="Direction", - description="The direction to find the closest strip", - items=[ - ("up", "Up", "The direction up from the selected strip"), - ("down", "Down", "The direction down from the selected strip"), - ], - default="up", - ) - - @classmethod - def poll(cls, context): +import bpy +from operator import attrgetter + +from .utils.doc import doc_name, doc_idname, doc_brief, doc_description + + +class POWER_SEQUENCER_OT_swap_strips(bpy.types.Operator): + """ + *brief* Swaps the 2 strips between them + + + Places the first strip in the channel and starting frame (frame_final_start) of the second + strip, and places the second strip in the channel and starting frame (frame_final_end) of + the first strip. If there is no space for the swap, it does nothing. + """ + + doc = { + "name": doc_name(__qualname__), + "demo": "", + "description": doc_description(__doc__), + "shortcuts": [], + "keymap": "Sequencer", + } + bl_idname = doc_idname(__qualname__) + bl_label = doc["name"] + bl_description = doc_brief(doc["description"]) + bl_options = {"REGISTER", "UNDO"} + + direction: bpy.props.EnumProperty( + name="Direction", + description="The direction to find the closest strip", + items=[ + ("up", "Up", "The direction up from the selected strip"), + ("down", "Down", "The direction down from the selected strip"), + ], + default="up", + ) + + @classmethod + def poll(cls, context): return context.selected_sequences - - def execute(self, context): - strip_1 = context.selected_sequences[0] - if len(context.selected_sequences) == 1: - strip_2 = self.find_closest_strip_vertical(context, strip_1, self.direction) - else: - strip_2 = context.selected_sequences[1] - if not strip_2 or strip_1.lock or strip_2.lock: - return {"CANCELLED"} - - # Swap a strip and one of its effects - if hasattr(strip_1, "input_1") or hasattr(strip_2, "input_1"): - if not self.are_linked(strip_1, strip_2): - return {"CANCELLED"} - self.swap_with_effect(strip_1, strip_2) - return {"FINISHED"} - - s1_start, s1_channel = strip_1.frame_final_start, strip_1.channel - s2_start, s2_channel = strip_2.frame_final_start, strip_2.channel - - self.move_to_end(strip_1, context) - self.move_to_end(strip_2, context) - - s1_start_2 = strip_1.frame_final_start - s2_start_2 = strip_2.frame_final_start - - group_1 = { - s: s.channel - for s in context.sequences - if s.frame_final_start == s1_start_2 and s != strip_1 - } - group_2 = { - s: s.channel - for s in context.sequences - if s.frame_final_start == s2_start_2 and s != strip_2 - } - - strip_2.select = False - bpy.ops.transform.seq_slide( - value=(s2_start - strip_1.frame_final_start, s2_channel - strip_1.channel) - ) - - bpy.ops.sequencer.select_all(action="DESELECT") - strip_2.select = True - bpy.ops.transform.seq_slide( - value=(s1_start - strip_2.frame_final_start, s1_channel - strip_2.channel) - ) - - if not self.fits( - strip_1, group_1, s2_start, s1_channel, s2_channel, context - ) or not self.fits(strip_2, group_2, s1_start, s2_channel, s1_channel, context): - self.reconstruct(strip_1, s1_channel, group_1, context) - self.reconstruct(strip_2, s2_channel, group_2, context) - - bpy.ops.sequencer.select_all(action="DESELECT") - strip_1.select = True - bpy.ops.transform.seq_slide( - value=(s1_start - strip_1.frame_final_start, s1_channel - strip_1.channel) - ) - - bpy.ops.sequencer.select_all(action="DESELECT") - strip_2.select = True - bpy.ops.transform.seq_slide( - value=(s2_start - strip_2.frame_final_start, s2_channel - strip_2.channel) - ) - - bpy.ops.sequencer.select_all(action="DESELECT") - strip_1.select = True - strip_2.select = True - return {"CANCELLED"} - - bpy.ops.sequencer.select_all(action="DESELECT") - strip_1.select = True - strip_2.select = True - return {"FINISHED"} - - def move_to_frame(self, strip, frame, context): - """ - Moves a strip based on its frame_final_start without changing its - duration. - Args: - - strip: The strip to be moved. - - frame: The frame, the frame_final_start of the strip will be placed - at. - """ - selected_strips = context.selected_sequences - bpy.ops.sequencer.select_all(action="DESELECT") - strip.select = True - - bpy.ops.transform.seq_slide(value=(frame - strip.frame_final_start, 0)) - - bpy.ops.sequencer.select_all(action="DESELECT") - for s in selected_strips: - s.select = True - - def move_to_end(self, strip, context): - """ - Moves a strip to an empty slot at the end of the sequencer, different - than its initial slot. - Args: - - strip: The strip to move. - """ - end_frame = max(context.sequences, key=attrgetter("frame_final_end")).frame_final_end - self.move_to_frame(strip, end_frame, context) - - def fits(self, strip, group, frame, init_channel, target_channel, context): - """ - Checks if a swap has been successful or not. - Args: - - strip: The core strip of the swap. - - group: The effect strips of the core strip. - - frame: The starting frame of the target location. - - init_channel: The initial channel of the strip, before the swap took - place. - - target_channel: The channel of the target location. - Returns: True if the swap was successful, otherwise False. - """ - if strip.frame_final_start != frame or strip.channel != target_channel: - return False - - offset = strip.channel - init_channel - for s in group.keys(): - if s.channel != group[s] + offset: - return False - - return context.selected_sequences - - def reconstruct(self, strip, init_channel, group, context): - """ - Reconstructs a failed swap, based on a core strip. After its done, the - core strip is placed at the end of the sequencer, in an empty slot. - Args: - - strip: The core strip of the swap. - - init_channel: The initial channel of the core strip. - - group: A dictionary with the effect strips of the core strip, and - their target channels. - """ - self.move_to_end(strip, context) - bpy.ops.sequencer.select_all(action="DESELECT") - strip.select = True - bpy.ops.transform.seq_slide(value=(0, init_channel - strip.channel)) - - for s in group.keys(): - channel = group[s] - for u in group.keys(): - if u.channel == channel and u != s: - u.channel += 1 - s.channel = channel - - def find_closest_strip_vertical(self, context, strip, direction): - """ - Finds the closest strip to a given strip in a specific direction. - Args: - - strip: The base strip. - Returns: The closest strip to the given strip, in the proper direction. - If no strip is found, returns None. - """ - strips_in_range = ( - s - for s in context.sequences - if strip.frame_final_start <= s.frame_final_start - and s.frame_final_end <= strip.frame_final_end - ) - if direction == "up": - strips_above = [s for s in strips_in_range if s.channel > strip.channel] - if not strips_above: - return - return min(strips_above, key=attrgetter("channel")) - elif direction == "down": - strips_below = [s for s in strips_in_range if s.channel < strip.channel] - if not strips_below: - return - return max(strips_below, key=attrgetter("channel")) - - def are_linked(self, strip_1, strip_2): - return ( - strip_1.frame_final_start == strip_2.frame_final_start - and strip_1.frame_final_end == strip_2.frame_final_end - ) - - def swap_with_effect(self, strip_1, strip_2): - effect_strip = strip_1 if hasattr(strip_1, "input_1") else strip_2 - other_strip = strip_1 if effect_strip != strip_1 else strip_2 - - effect_strip_channel = effect_strip.channel - other_strip_channel = other_strip.channel - - effect_strip.channel -= 1 - other_strip.channel = effect_strip_channel - effect_strip.channel = other_strip_channel + + def execute(self, context): + strip_1 = context.selected_sequences[0] + if len(context.selected_sequences) == 1: + strip_2 = self.find_closest_strip_vertical(context, strip_1, self.direction) + else: + strip_2 = context.selected_sequences[1] + if not strip_2 or strip_1.lock or strip_2.lock: + return {"CANCELLED"} + + # Swap a strip and one of its effects + if hasattr(strip_1, "input_1") or hasattr(strip_2, "input_1"): + if not self.are_linked(strip_1, strip_2): + return {"CANCELLED"} + self.swap_with_effect(strip_1, strip_2) + return {"FINISHED"} + + s1_start, s1_channel = strip_1.frame_final_start, strip_1.channel + s2_start, s2_channel = strip_2.frame_final_start, strip_2.channel + + self.move_to_end(strip_1, context) + self.move_to_end(strip_2, context) + + s1_start_2 = strip_1.frame_final_start + s2_start_2 = strip_2.frame_final_start + + group_1 = { + s: s.channel + for s in context.sequences + if s.frame_final_start == s1_start_2 and s != strip_1 + } + group_2 = { + s: s.channel + for s in context.sequences + if s.frame_final_start == s2_start_2 and s != strip_2 + } + + strip_2.select = False + bpy.ops.transform.seq_slide( + value=(s2_start - strip_1.frame_final_start, s2_channel - strip_1.channel) + ) + + bpy.ops.sequencer.select_all(action="DESELECT") + strip_2.select = True + bpy.ops.transform.seq_slide( + value=(s1_start - strip_2.frame_final_start, s1_channel - strip_2.channel) + ) + + if not self.fits( + strip_1, group_1, s2_start, s1_channel, s2_channel, context + ) or not self.fits(strip_2, group_2, s1_start, s2_channel, s1_channel, context): + self.reconstruct(strip_1, s1_channel, group_1, context) + self.reconstruct(strip_2, s2_channel, group_2, context) + + bpy.ops.sequencer.select_all(action="DESELECT") + strip_1.select = True + bpy.ops.transform.seq_slide( + value=(s1_start - strip_1.frame_final_start, s1_channel - strip_1.channel) + ) + + bpy.ops.sequencer.select_all(action="DESELECT") + strip_2.select = True + bpy.ops.transform.seq_slide( + value=(s2_start - strip_2.frame_final_start, s2_channel - strip_2.channel) + ) + + bpy.ops.sequencer.select_all(action="DESELECT") + strip_1.select = True + strip_2.select = True + return {"CANCELLED"} + + bpy.ops.sequencer.select_all(action="DESELECT") + strip_1.select = True + strip_2.select = True + return {"FINISHED"} + + def move_to_frame(self, strip, frame, context): + """ + Moves a strip based on its frame_final_start without changing its + duration. + Args: + - strip: The strip to be moved. + - frame: The frame, the frame_final_start of the strip will be placed + at. + """ + selected_strips = context.selected_sequences + bpy.ops.sequencer.select_all(action="DESELECT") + strip.select = True + + bpy.ops.transform.seq_slide(value=(frame - strip.frame_final_start, 0)) + + bpy.ops.sequencer.select_all(action="DESELECT") + for s in selected_strips: + s.select = True + + def move_to_end(self, strip, context): + """ + Moves a strip to an empty slot at the end of the sequencer, different + than its initial slot. + Args: + - strip: The strip to move. + """ + end_frame = max(context.sequences, key=attrgetter("frame_final_end")).frame_final_end + self.move_to_frame(strip, end_frame, context) + + def fits(self, strip, group, frame, init_channel, target_channel, context): + """ + Checks if a swap has been successful or not. + Args: + - strip: The core strip of the swap. + - group: The effect strips of the core strip. + - frame: The starting frame of the target location. + - init_channel: The initial channel of the strip, before the swap took + place. + - target_channel: The channel of the target location. + Returns: True if the swap was successful, otherwise False. + """ + if strip.frame_final_start != frame or strip.channel != target_channel: + return False + + offset = strip.channel - init_channel + for s in group.keys(): + if s.channel != group[s] + offset: + return False + + return context.selected_sequences + + def reconstruct(self, strip, init_channel, group, context): + """ + Reconstructs a failed swap, based on a core strip. After its done, the + core strip is placed at the end of the sequencer, in an empty slot. + Args: + - strip: The core strip of the swap. + - init_channel: The initial channel of the core strip. + - group: A dictionary with the effect strips of the core strip, and + their target channels. + """ + self.move_to_end(strip, context) + bpy.ops.sequencer.select_all(action="DESELECT") + strip.select = True + bpy.ops.transform.seq_slide(value=(0, init_channel - strip.channel)) + + for s in group.keys(): + channel = group[s] + for u in group.keys(): + if u.channel == channel and u != s: + u.channel += 1 + s.channel = channel + + def find_closest_strip_vertical(self, context, strip, direction): + """ + Finds the closest strip to a given strip in a specific direction. + Args: + - strip: The base strip. + Returns: The closest strip to the given strip, in the proper direction. + If no strip is found, returns None. + """ + strips_in_range = ( + s + for s in context.sequences + if strip.frame_final_start <= s.frame_final_start + and s.frame_final_end <= strip.frame_final_end + ) + if direction == "up": + strips_above = [s for s in strips_in_range if s.channel > strip.channel] + if not strips_above: + return + return min(strips_above, key=attrgetter("channel")) + elif direction == "down": + strips_below = [s for s in strips_in_range if s.channel < strip.channel] + if not strips_below: + return + return max(strips_below, key=attrgetter("channel")) + + def are_linked(self, strip_1, strip_2): + return ( + strip_1.frame_final_start == strip_2.frame_final_start + and strip_1.frame_final_end == strip_2.frame_final_end + ) + + def swap_with_effect(self, strip_1, strip_2): + effect_strip = strip_1 if hasattr(strip_1, "input_1") else strip_2 + other_strip = strip_1 if effect_strip != strip_1 else strip_2 + + effect_strip_channel = effect_strip.channel + other_strip_channel = other_strip.channel + + effect_strip.channel -= 1 + other_strip.channel = effect_strip_channel + effect_strip.channel = other_strip_channel diff --git a/presets/pov/light/17_(1700K)_135W_Low_Pressure_Sodium.py b/presets/pov/light/17_(1700K)_135W_Low_Pressure_Sodium.py index d5e4267845a3bff8fd103a304724d962df24ed5d..a6486c019a1a6b5f874e24b05a2493e4af87bbd2 100644 --- a/presets/pov/light/17_(1700K)_135W_Low_Pressure_Sodium.py +++ b/presets/pov/light/17_(1700K)_135W_Low_Pressure_Sodium.py @@ -1,5 +1,5 @@ #(1700K) 135W Low Pressure Sodium Vapor Starting from 1932 -#Mostly used for Outdoor city lighting, security lighting, long tunnel lighting +#Mostly used for Outdoor city lighting, security lighting, long tunnel lighting import bpy bpy.context.object.data.type = 'POINT' diff --git a/presets/pov/world/4_Cartoony_Sky.py b/presets/pov/world/4_Cartoony_Sky.py index f38a7b9712b6b30b153b324f22c938ebd4253474..90b87bf509e7b1f46ffb5c84dcdd2747688fe4a8 100644 --- a/presets/pov/world/4_Cartoony_Sky.py +++ b/presets/pov/world/4_Cartoony_Sky.py @@ -2,7 +2,7 @@ import bpy scene = bpy.context.scene scene.world.pov.use_sky_blend = True -#below multiplied by two for a better proportion Clear vs Overcast sky +#below multiplied by two for a better proportion Clear vs Overcast sky #since Clear sky is 20000 lux vs 2000 for overcast scene.world.pov.horizon_color = (0.350*2, 0.611*2, 1.0*2) scene.world.pov.zenith_color = (0.05000000074505806*2, 0.125*2, 0.5*2) diff --git a/presets/pov/world/5_Under_Water.py b/presets/pov/world/5_Under_Water.py index 44b33a386beaf14b1e50176f3cf7ae93dd8afb3c..36af41961b668db3923f78cd846d94c0393b0889 100644 --- a/presets/pov/world/5_Under_Water.py +++ b/presets/pov/world/5_Under_Water.py @@ -2,7 +2,7 @@ import bpy scene = bpy.context.scene scene.world.pov.use_sky_blend = True -#below multiplied by two for a better proportion Clear vs Overcast sky +#below multiplied by two for a better proportion Clear vs Overcast sky #since Clear sky is 20000 lux vs 2000 for overcast scene.world.pov.horizon_color = (0.0, 0.0, 0.0) scene.world.pov.zenith_color = (0.250980406999588, 0.6117647290229797, 1.0) diff --git a/space_view3d_brush_menus/__init__.py b/space_view3d_brush_menus/__init__.py index 1a8d677afc20feb66e08436f838a2313085c4cb0..dbc16a5ef0011cf269227b8b93705d9890a1742f 100644 --- a/space_view3d_brush_menus/__init__.py +++ b/space_view3d_brush_menus/__init__.py @@ -69,12 +69,12 @@ addon_files = ( symmetry_menu, texture_menu, ) - + class VIEW3D_MT_Brushes_Pref(AddonPreferences): bl_idname = __name__ - + column_set: IntProperty( name="Number of Columns", description="Number of columns used for the brushes menu", @@ -99,10 +99,10 @@ def register(): # register all files for addon_file in addon_files: addon_file.register() - + # set the add-on name variable to access the preferences utils_core.get_addon_name = __name__ - + # register preferences bpy.utils.register_class(VIEW3D_MT_Brushes_Pref) @@ -121,10 +121,10 @@ def unregister(): # unregister all files for addon_file in addon_files: addon_file.unregister() - + # unregister preferences bpy.utils.unregister_class(VIEW3D_MT_Brushes_Pref) - + for km, kmi in addon_keymaps: km.keymap_items.remove(kmi) addon_keymaps.clear() diff --git a/space_view3d_brush_menus/brush_menu.py b/space_view3d_brush_menus/brush_menu.py index 339a211c5b6e7bca2930b1f1b4efe4a6062fed2a..ee7eff25f12248e1a47d51c175a3b48b024aeb4e 100644 --- a/space_view3d_brush_menus/brush_menu.py +++ b/space_view3d_brush_menus/brush_menu.py @@ -25,7 +25,7 @@ class BrushOptionsMenu(Menu): def draw(self, context): mode = utils_core.get_mode() layout = self.layout - + # add generic menu items layout.operator_context = 'INVOKE_REGION_WIN' layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM') @@ -34,8 +34,8 @@ class BrushOptionsMenu(Menu): layout.operator_menu_enum("object.mode_set", "mode", text="Interactive Mode", icon='VIEW3D') layout.separator() - - + + # add mode specific menu items if mode == 'SCULPT': self.sculpt(mode, layout, context) @@ -53,7 +53,7 @@ class BrushOptionsMenu(Menu): has_brush = utils_core.get_brush_link(context, types="brush") icons = brushes.brush_icon[mode][has_brush.sculpt_tool] if \ has_brush else "BRUSH_DATA" - + layout.row().menu("VIEW3D_MT_sv3_brushes_menu", icon=icons) @@ -75,8 +75,8 @@ class BrushOptionsMenu(Menu): has_brush = utils_core.get_brush_link(context, types="brush") icons = brushes.brush_icon[mode][has_brush.vertex_tool] if \ has_brush else "BRUSH_DATA" - - if mode == 'VERTEX_PAINT': + + if mode == 'VERTEX_PAINT': layout.row().operator(ColorPickerPopup.bl_idname, icon="COLOR") layout.row().separator() @@ -107,7 +107,7 @@ class BrushOptionsMenu(Menu): def texpaint(self, mode, layout, context): toolsettings = context.tool_settings.image_paint - + has_brush = utils_core.get_brush_link(context, types="brush") icons = brushes.brush_icon[mode][has_brush.image_tool] if \ has_brush else "BRUSH_DATA" @@ -116,36 +116,36 @@ class BrushOptionsMenu(Menu): if toolsettings.missing_uvs: layout.row().label(text="Missing UVs", icon='ERROR') layout.row().operator("paint.add_simple_uvs") - + return - + elif toolsettings.missing_materials or toolsettings.missing_texture: layout.row().label(text="Missing Data", icon='ERROR') layout.row().operator_menu_enum("paint.add_texture_paint_slot", \ "type", \ icon='ADD', \ text="Add Texture Paint Slot") - + return - + elif toolsettings.missing_stencil: layout.row().label(text="Missing Data", icon='ERROR') layout.row().label(text="See Mask Properties", icon='FORWARD') layout.row().separator() layout.row().menu("VIEW3D_MT_sv3_brushes_menu", icon=icons) - + return - + else: layout.row().label(text="Missing Data", icon="INFO") - + else: if has_brush and has_brush.image_tool in {'DRAW', 'FILL'} and \ has_brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'}: layout.row().operator(ColorPickerPopup.bl_idname, icon="COLOR") layout.row().separator() - + layout.row().menu("VIEW3D_MT_sv3_brushes_menu", icon=icons) diff --git a/space_view3d_brush_menus/brushes.py b/space_view3d_brush_menus/brushes.py index 4d99b7d500ca7eadd9b91f3a844a85f6b7acc322..0d70227d36bc7262d2de973b66e8d168cac39214 100644 --- a/space_view3d_brush_menus/brushes.py +++ b/space_view3d_brush_menus/brushes.py @@ -110,7 +110,7 @@ class BrushesMenu(Menu): ) else: column_flow = layout.column_flow(columns=colum_n) - + # iterate over all the brushes for item in bpy.data.brushes: if mode == 'SCULPT': diff --git a/space_view3d_pie_menus/pie_apply_transform_menu.py b/space_view3d_pie_menus/pie_apply_transform_menu.py index 1b32aa32f313d5f7541491b9e63bfaaa4d13941c..545b4003b191c0e83e3d397ee9b2e6cce301d6cb 100644 --- a/space_view3d_pie_menus/pie_apply_transform_menu.py +++ b/space_view3d_pie_menus/pie_apply_transform_menu.py @@ -47,7 +47,7 @@ class PIE_MT_PieApplyTransforms(Menu): layout = self.layout pie = layout.menu_pie() # 4 - LEFT - pie.operator("object.visual_transform_apply", text="Apply Visual") + pie.operator("object.visual_transform_apply", text="Apply Visual") # 6 - RIGHT pie.operator("apply.transformall", text="Apply All") # 2 - BOTTOM diff --git a/space_view3d_pie_menus/pie_editor_switch_menu.py b/space_view3d_pie_menus/pie_editor_switch_menu.py index 0b07ea9ed4bb66440be26a3821829aacdf62405f..d648217f1ee97ddfb06e2c410894f07d67a77762 100644 --- a/space_view3d_pie_menus/pie_editor_switch_menu.py +++ b/space_view3d_pie_menus/pie_editor_switch_menu.py @@ -78,7 +78,7 @@ class PIE_MT_AreaTypePieOther(Menu): self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="File Browser", icon="FILEBROWSER").types = "FILE_BROWSER" self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Preferences", icon="PREFERENCES").types = "PREFERENCES" - self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Text Editor", icon="TEXT").types = "TEXT_EDITOR" + self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Text Editor", icon="TEXT").types = "TEXT_EDITOR" self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Python Console", icon="CONSOLE").types = "CONSOLE" self.layout.operator(PIE_OT_SetAreaType.bl_idname, text="Info", icon="INFO").types = "INFO" diff --git a/space_view3d_pie_menus/pie_modes_menu.py b/space_view3d_pie_menus/pie_modes_menu.py index 1f4f15a126aeaa3aa2429f1bf9669ddf5d38059d..62273c2bd7962bd742e1ffbf68654d192894cc65 100644 --- a/space_view3d_pie_menus/pie_modes_menu.py +++ b/space_view3d_pie_menus/pie_modes_menu.py @@ -132,7 +132,7 @@ class PIE_OT_SetObjectModePie(Operator): return {'FINISHED'} -# Edit Selection Modes +# Edit Selection Modes class PIE_OT_ClassVertex(Operator): bl_idname = "class.vertex" bl_label = "Class Vertex" @@ -223,7 +223,7 @@ class PIE_MT_ObjectEditMode(Menu): ob = context.object # No Object Selected # if not ob or not ob.select_get(): - message = "No Active Object Selected" + message = "No Active Object Selected" pie = layout.menu_pie() pie.separator() pie.separator() @@ -383,7 +383,7 @@ class PIE_MT_ObjectEditMode(Menu): elif ob and ob.type in {"LIGHT", "CAMERA", "EMPTY", "SPEAKER"}: - message = "Active Object has only Object Mode available" + message = "Active Object has only Object Mode available" pie = layout.menu_pie() pie.separator() pie.separator() @@ -408,7 +408,7 @@ classes = ( ) addon_keymaps = [] - + def register(): for cls in classes: diff --git a/space_view3d_pie_menus/pie_origin.py b/space_view3d_pie_menus/pie_origin.py index 53448db2ab2e0d1d126aa901122d6ba032143cf7..9fc36898a8a72fa1eba50d82171fce408c3df968 100644 --- a/space_view3d_pie_menus/pie_origin.py +++ b/space_view3d_pie_menus/pie_origin.py @@ -267,7 +267,7 @@ class PIE_MT_OriginPivot(Menu): icon='NONE').type = 'ORIGIN_GEOMETRY' - elif obj and obj.type == 'MESH' and obj.mode in {'EDIT'}: + elif obj and obj.type == 'MESH' and obj.mode in {'EDIT'}: # 4 - LEFT pie.operator("object.origintomass_edit", text="Origin to Center of Mass", icon='NONE') @@ -279,7 +279,7 @@ class PIE_MT_OriginPivot(Menu): icon='TRIA_DOWN') # 8 - TOP pie.operator("object.setorigintoselected_edit", text="Origin To Selected", - icon='SNAP_INCREMENT') + icon='SNAP_INCREMENT') # 7 - TOP - LEFT pie.operator("object.geometrytoorigin_edit", text="Geometry To Origin", icon='NONE') diff --git a/space_view3d_pie_menus/pie_proportional_menu.py b/space_view3d_pie_menus/pie_proportional_menu.py index 7dcc6346b69ea7a6067f49bafafb2e5db696b828..81312c7276683039f2ce62b8f125014889b8887a 100644 --- a/space_view3d_pie_menus/pie_proportional_menu.py +++ b/space_view3d_pie_menus/pie_proportional_menu.py @@ -298,7 +298,7 @@ class PIE_OT_ProportionalRandomEdt(Operator): ts.use_proportional_edit = True ts.proportional_edit_falloff = 'RANDOM' return {'FINISHED'} - + class PIE_OT_ProportionalInverseSquareEdt(Operator): bl_idname = "proportional_edt.inversesquare" bl_label = "Proportional Inverese Square EditMode" diff --git a/space_view3d_spacebar_menu/__init__.py b/space_view3d_spacebar_menu/__init__.py index 8cb0a427d26f35ada7602a754201ac8ea482c370..5694c3fa0e58640f570e8ecf962b721825390216 100644 --- a/space_view3d_spacebar_menu/__init__.py +++ b/space_view3d_spacebar_menu/__init__.py @@ -379,7 +379,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(Menu): layout.operator("mball.duplicate_metaelems", icon='OUTLINER_DATA_META') layout.menu("VIEW3D_MT_edit_meta_showhide", icon='HIDE_OFF') UseSeparator(self, context) - layout.operator("mball.delete_metaelems", text="Delete", icon='X') + layout.operator("mball.delete_metaelems", text="Delete", icon='X') UseSeparator(self, context) layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')