Skip to content

Commit

Permalink
feat: detect additional existing mods in fast menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed May 29, 2022
1 parent 675af08 commit c0a5963
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions interface/fast_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,41 @@ def draw_single_object_predictions(self, context):

mod_names = [mod.name for mod in context.object.modifiers]

has_mod_pe = False
has_mod_sol = False
has_mod_bool = False
has_mod_profile_extrude = False
has_mod_solidify = False
has_mod_boolean = False
has_mod_screw = False
has_mod_array_cubed = False
has_mod_circular_array = False

for name in mod_names:
has_mod_pe = has_mod_pe or bool("— ND PE" in name)
has_mod_sol = has_mod_sol or bool("— ND SOL" in name)
has_mod_bool = has_mod_bool or bool("— ND Bool" in name)
has_mod_profile_extrude = has_mod_profile_extrude or bool("— ND PE" in name)
has_mod_solidify = has_mod_solidify or bool("— ND SOL" in name)
has_mod_boolean = has_mod_boolean or bool("— ND Bool" in name)
has_mod_screw = has_mod_screw or bool("— ND SCR" in name)
has_mod_array_cubed = has_mod_array_cubed or bool("Array³" in name)
has_mod_circular_array = has_mod_circular_array or bool("— ND CA" in name)

was_profile_extrude = has_mod_pe and not has_mod_sol
was_profile_extrude = has_mod_profile_extrude and not has_mod_solidify

if has_mod_bool:
if has_mod_boolean:
layout.operator("nd.cycle", icon='LONGDISPLAY')
layout.separator()

if has_mod_sol:
if has_mod_solidify:
layout.operator("nd.solidify", icon='MOD_SOLIDIFY')

if has_mod_pe:
if has_mod_profile_extrude:
layout.operator("nd.profile_extrude", icon='EMPTY_SINGLE_ARROW')

if has_mod_screw:
layout.operator("nd.screw", icon='MOD_SCREW')

if has_mod_array_cubed:
layout.operator("nd.array_cubed", icon='PARTICLES')

if has_mod_circular_array:
layout.operator("nd.circular_array", icon='DRIVER_ROTATIONAL_DIFFERENCE')

if "Bool —" in context.object.name:
layout.operator("nd.hydrate", icon='SHADING_RENDERED')
Expand All @@ -183,16 +198,16 @@ def draw_single_object_predictions(self, context):
return

if was_profile_extrude or self.sketch:
layout.operator("nd.solidify", icon='MOD_SOLIDIFY')
layout.operator("nd.solidify", icon='MOD_SOLIDIFY') if not has_mod_solidify else None
layout.separator()
layout.operator("nd.mirror", icon='MOD_MIRROR')
layout.operator("nd.screw", icon='MOD_SCREW')
layout.operator("nd.screw", icon='MOD_SCREW') if not has_mod_screw else None

return

if self.profile:
layout.operator("nd.profile_extrude", icon='EMPTY_SINGLE_ARROW')
layout.operator("nd.screw", icon='MOD_SCREW')
layout.operator("nd.profile_extrude", icon='EMPTY_SINGLE_ARROW') if not has_mod_profile_extrude else None
layout.operator("nd.screw", icon='MOD_SCREW') if not has_mod_screw else None
layout.operator("nd.mirror", icon='MOD_MIRROR')

return
Expand All @@ -202,8 +217,8 @@ def draw_single_object_predictions(self, context):
layout.operator("nd.bevel", icon='MOD_BEVEL')
layout.operator("nd.weighted_normal_bevel", icon='MOD_BEVEL')
layout.separator()
layout.operator("nd.array_cubed", icon='PARTICLES')
layout.operator("nd.circular_array", icon='DRIVER_ROTATIONAL_DIFFERENCE')
layout.operator("nd.array_cubed", icon='PARTICLES') if not has_mod_array_cubed else None
layout.operator("nd.circular_array", icon='DRIVER_ROTATIONAL_DIFFERENCE') if not has_mod_circular_array else None
layout.operator("nd.mirror", icon='MOD_MIRROR')

return
Expand Down

0 comments on commit c0a5963

Please sign in to comment.