Skip to content

Commit

Permalink
fix: fix mesh_f2 addon detection in the Fast Predict menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-hm committed Jun 24, 2022
1 parent 6bcbe76 commit 499d96a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
14 changes: 9 additions & 5 deletions interface/fast_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .. import bl_info
from .. lib.objects import is_planar
from . ops import build_icon_lookup_table
from .. lib.addons import is_addon_enabled


keys = []
Expand Down Expand Up @@ -62,11 +63,14 @@ def draw_make_edge_face_ops(self, context):
layout.operator_context = 'INVOKE_DEFAULT'

layout.separator()

try:
layout.operator("mesh.f2", text="[F] Make Edge/Face", icon='MOD_SIMPLIFY')
except:
layout.operator("mesh.edge_face_add", text="[F] Make Edge/Face", icon='MOD_SIMPLIFY')

text = "F » Make Edge/Face"
icon = 'MOD_SIMPLIFY'

if is_addon_enabled("mesh_f2"):
layout.operator("mesh.f2", text=text, icon=icon)
else:
layout.operator("mesh.edge_face_add", text=text, icon=icon)


def draw_no_object_predictions(self, context):
Expand Down
2 changes: 2 additions & 0 deletions lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from . import assets
from . import updates
from . import preferences
from . import addons
from . import collections
from . import modifiers
from . import numeric_input
Expand All @@ -46,6 +47,7 @@
assets,
updates,
preferences,
addons,
collections,
modifiers,
numeric_input,
Expand Down
33 changes: 33 additions & 0 deletions lib/addons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ███╗ ██╗██████╗
# ████╗ ██║██╔══██╗
# ██╔██╗ ██║██║ ██║
# ██║╚██╗██║██║ ██║
# ██║ ╚████║██████╔╝
# ╚═╝ ╚═══╝╚═════╝
#
# “Commons Clause” License Condition v1.0
#
# See LICENSE for license details. If you did not receive a copy of the license,
# it may be obtained at https://github.com/hugemenace/nd/blob/main/LICENSE.
#
# Software: ND Blender Addon
# License: MIT
# Licensor: T.S. & I.J. (HugeMenace)
#
# ---
# Contributors: Tristo (HM)
# ---

import bpy


def get_registered_addon_name():
return __name__.partition('.')[0]


def is_addon_enabled(addon):
for key in bpy.context.preferences.addons.keys():
if addon == key:
return True

return False
7 changes: 2 additions & 5 deletions lib/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
# ---

import bpy


def get_registered_addon_name():
return __name__.partition('.')[0]
from . addons import get_registered_addon_name


def get_preferences():
return bpy.context.preferences.addons[get_registered_addon_name()].preferences
return bpy.context.preferences.addons[get_registered_addon_name()].preferences

0 comments on commit 499d96a

Please sign in to comment.