Skip to content

Commit

Permalink
feat: automatically collapse new modifiers added to objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 12, 2022
1 parent ee5c03d commit 752de82
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bevels/bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def add_bevel_modifier(self, context):
bevel = context.active_object.modifiers.new(mod_bevel, 'BEVEL')
bevel.offset_type = 'WIDTH'
bevel.miter_outer = 'MITER_ARC'
bevel.show_expanded = False

self.bevel = bevel

Expand All @@ -243,6 +244,7 @@ def add_weld_modifier(self, context):
if not previous_op:
weld = context.active_object.modifiers.new(mod_weld, type='WELD')
weld.merge_threshold = 0.00001
weld.show_expanded = False

self.weld = weld

Expand Down
2 changes: 2 additions & 0 deletions bevels/edge_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def add_bevel_modifier(self, context):
bevel = context.active_object.modifiers.new(mod_bevel, 'BEVEL')
bevel.offset_type = 'WIDTH'
bevel.limit_method = 'WEIGHT'
bevel.show_expanded = False

self.bevel = bevel

Expand All @@ -266,6 +267,7 @@ def add_weld_modifier(self, context):
if not previous_op:
weld = context.active_object.modifiers.new(mod_weld, type='WELD')
weld.merge_threshold = 0.00001
weld.show_expanded = False

self.weld = weld

Expand Down
2 changes: 2 additions & 0 deletions bevels/vertex_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def add_bevel_modifier(self, context):
bevel.limit_method = 'VGROUP'
bevel.offset_type = 'WIDTH'
bevel.vertex_group = self.vgroup.name
bevel.show_expanded = False

self.bevel = bevel

Expand All @@ -282,6 +283,7 @@ def add_weld_modifier(self, context):
if self.late_apply or not previous_op:
weld = context.active_object.modifiers.new(mod_weld_la if self.late_apply else mod_weld, type='WELD')
weld.merge_threshold = 0.00001
weld.show_expanded = False

self.weld = weld

Expand Down
2 changes: 2 additions & 0 deletions bevels/weighted_normal_bevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def add_bevel_modifier(self, context):
bevel.segments = 1
bevel.offset_type = 'WIDTH'
bevel.face_strength_mode = 'FSTR_AFFECTED'
bevel.show_expanded = False

self.bevel = bevel

Expand All @@ -197,6 +198,7 @@ def add_weighted_normal_modifer(self, context):
wn = context.active_object.modifiers.new(mod_wn, 'WEIGHTED_NORMAL')
wn.weight = 100
wn.use_face_influence = True
wn.show_expanded = False

self.wn = wn

Expand Down
3 changes: 3 additions & 0 deletions booleans/boolean_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,20 @@ def invoke(self, context, event):
self.boolean_diff.operation = 'UNION' if self.outset else 'DIFFERENCE'
self.boolean_diff.object = self.intersecting_obj
self.boolean_diff.solver = solver
self.boolean_diff.show_expanded = False

rectify_mod_order(self.target_obj, self.boolean_diff.name)

self.solidify = self.intersecting_obj.modifiers.new("Thickness — ND Bool", 'SOLIDIFY')
self.solidify.use_even_offset = True
self.solidify.offset = 0
self.solidify.show_expanded = False

self.boolean_isect = self.intersecting_obj.modifiers.new("Intersection — ND Bool", 'BOOLEAN')
self.boolean_isect.operation = 'INTERSECT'
self.boolean_isect.object = self.reference_obj
self.boolean_isect.solver = solver
self.boolean_isect.show_expanded = False

remove_problematic_bevels(self.intersecting_obj)

Expand Down
2 changes: 2 additions & 0 deletions booleans/boolean_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ def execute(self, context):
boolean_diff.operation = 'DIFFERENCE'
boolean_diff.object = reference_obj
boolean_diff.solver = solver
boolean_diff.show_expanded = False

rectify_mod_order(difference_obj, boolean_diff.name)

boolean_isect = intersecting_obj.modifiers.new("Intersection — ND Bool", 'BOOLEAN')
boolean_isect.operation = 'INTERSECT'
boolean_isect.object = reference_obj
boolean_isect.solver = solver
boolean_isect.show_expanded = False

rectify_mod_order(intersecting_obj, boolean_isect.name)

Expand Down
1 change: 1 addition & 0 deletions booleans/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def execute(self, context):
boolean.operation = self.mode
boolean.object = reference_obj
boolean.solver = solver
boolean.show_expanded = False

rectify_mod_order(context.active_object, boolean.name)

Expand Down
1 change: 1 addition & 0 deletions deform/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def select_lattice_object(self, context):
def add_lattice_modifier(self, context):
lattice = context.active_object.modifiers.new(mod_lattice, 'LATTICE')
lattice.object = self.lattice_obj
lattice.show_expanded = False

self.lattice = lattice

Expand Down
1 change: 1 addition & 0 deletions deform/simple_deform.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def summon_old_operator(self, context, mods):

def add_simple_deform_modifier(self, context):
deform = context.active_object.modifiers.new(mod_deform, 'SIMPLE_DEFORM')
deform.show_expanded = False

self.deform = deform

Expand Down
2 changes: 2 additions & 0 deletions extrusion/profile_extrude.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def add_offset_modifier(self, context):
offset = context.active_object.modifiers.new(mod_offset, 'DISPLACE')
offset.space = 'LOCAL'
offset.mid_level = 0
offset.show_expanded = False

self.offset = offset

Expand All @@ -210,6 +211,7 @@ def add_screw_modifier(self, context):
screw.render_steps = 0
screw.angle = 0
screw.use_normal_calculate = True
screw.show_expanded = False

self.screw = screw

Expand Down
2 changes: 2 additions & 0 deletions extrusion/screw.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def add_displace_modifier(self, context):
displace = context.active_object.modifiers.new(mod_displace, 'DISPLACE')
displace.mid_level = 0
displace.space = 'LOCAL'
displace.show_expanded = False

self.displace = displace

Expand All @@ -248,6 +249,7 @@ def add_screw_modifier(self, context):
screw.use_merge_vertices = True
screw.merge_threshold = 0.0001
screw.use_normal_calculate = True
screw.show_expanded = False

self.screw = screw

Expand Down
2 changes: 2 additions & 0 deletions extrusion/solidify.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,15 @@ def add_smooth_shading(self, context):
def add_displace_modifier(self, context):
displace = context.active_object.modifiers.new(mod_displace, 'DISPLACE')
displace.mid_level = 0
displace.show_expanded = False

self.displace = displace


def add_solidify_modifier(self, context):
solidify = context.active_object.modifiers.new(mod_solidify, 'SOLIDIFY')
solidify.use_even_offset = True
solidify.show_expanded = False

self.solidify = solidify

Expand Down
1 change: 1 addition & 0 deletions replicate/array_cubed.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def summon_old_operator(self, context, mods):
def add_array_modifier(self, context, name, axis):
array = context.active_object.modifiers.new(name, 'ARRAY')
array.use_relative_offset = True
array.show_expanded = False

self.axes[axis] = [array, 1, 2]

Expand Down
3 changes: 3 additions & 0 deletions replicate/circular_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def add_array_modifier(self):
array.use_relative_offset = False
array.use_object_offset = True
array.offset_object = self.rotator_obj
array.show_expanded = False

self.array = array

Expand All @@ -305,6 +306,7 @@ def add_displace_tranform_modifiers(self):
displace.show_in_editmode = True
displace.show_on_cage = True
displace.strength = self.reference_obj_prev_location[index] - self.reference_obj.location[index]
displace.show_expanded = False

self.displace_transforms.append(displace)

Expand All @@ -315,6 +317,7 @@ def add_displace_modifier(self):
displace.mid_level = 0
displace.show_in_editmode = True
displace.show_on_cage = True
displace.show_expanded = False

if self.single_obj_mode:
self.offset = self.reference_obj.dimensions[self.axis]
Expand Down
1 change: 1 addition & 0 deletions replicate/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def add_mirror_modifiers(self):
mirror = obj.modifiers.new('Mirror — ND', 'MIRROR')
mirror.use_clip = True
mirror.merge_threshold = 0.0001
mirror.show_expanded = False

if self.mirror_obj != None:
mirror.mirror_object = self.mirror_obj
Expand Down
1 change: 1 addition & 0 deletions simplify/decimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def invoke(self, context, event):
modifier = obj.modifiers.new('Decimate — ND SD', 'DECIMATE')
modifier.decimate_type = 'DISSOLVE'
modifier.angle_limit = radians(1)
modifier.show_expanded = False
rectify_mod_order(obj, modifier.name)

return {'FINISHED'}
Expand Down
1 change: 1 addition & 0 deletions simplify/weld.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def invoke(self, context, event):
for obj in context.selected_objects:
modifier = obj.modifiers.new('Weld — ND SW', 'WELD')
modifier.merge_threshold = 0.001
modifier.show_expanded = False
rectify_mod_order(obj, modifier.name)

return {'FINISHED'}
Expand Down
4 changes: 4 additions & 0 deletions sketch/recon_poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def add_displace_modifier(self):
displace.mid_level = 0
displace.direction = 'X'
displace.space = 'LOCAL'
displace.show_expanded = False

self.displace = displace

Expand All @@ -291,6 +292,7 @@ def add_screw_x_modifier(self):
screwX.render_steps = 1
screwX.use_merge_vertices = True
screwX.merge_threshold = 0.0001
screwX.show_expanded = False

self.screwX = screwX

Expand All @@ -301,6 +303,7 @@ def add_screw_z_modifer(self):
screwZ.use_merge_vertices = True
screwZ.merge_threshold = 0.0001
screwZ.use_normal_calculate = True
screwZ.show_expanded = False

self.screwZ = screwZ

Expand All @@ -309,6 +312,7 @@ def add_decimate_modifier(self):
decimate = self.obj.modifiers.new(mod_decimate, 'DECIMATE')
decimate.decimate_type = 'DISSOLVE'
decimate.angle_limit = radians(1)
decimate.show_expanded = False

self.decimate = decimate

Expand Down
1 change: 1 addition & 0 deletions sketch/screw_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def add_displace_modifier(self, context):
displace.direction = 'Z'
displace.space = 'LOCAL'
displace.mid_level = 0
displace.show_expanded = False

self.displace = displace

Expand Down
1 change: 1 addition & 0 deletions utils/set_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def add_displace_modifier(self, reference_obj, axis, strength):
displace.space = 'GLOBAL'
displace.mid_level = 0
displace.strength = strength
displace.show_expanded = False


def register():
Expand Down
1 change: 1 addition & 0 deletions utils/triangulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def invoke(self, context, event):
modifier = obj.modifiers.new('Triangulate — ND', 'TRIANGULATE')
modifier.keep_custom_normals = self.preserve_normals
modifier.quad_method = 'FIXED' if self.preserve_normals else 'BEAUTY'
modifier.show_expanded = False

return {'FINISHED'}

Expand Down

0 comments on commit 752de82

Please sign in to comment.