From d75939604582fda89e08502b5a88663a9bed4ae8 Mon Sep 17 00:00:00 2001 From: Taremin Date: Sat, 5 Mar 2022 14:05:21 +0900 Subject: [PATCH] fix circular import --- __init__.py | 1 + lib/lacing_base.py | 6 +++--- lib/ops.py | 13 ++----------- lib/utils.py | 9 +++++++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/__init__.py b/__init__.py index b85f86d..c0bbafd 100644 --- a/__init__.py +++ b/__init__.py @@ -8,6 +8,7 @@ # モジュール読み込み module_names = [ + "utils", "library", "lacing_base", "lacing_bow_tie", diff --git a/lib/lacing_base.py b/lib/lacing_base.py index 563c1bc..0e24589 100644 --- a/lib/lacing_base.py +++ b/lib/lacing_base.py @@ -3,7 +3,7 @@ import mathutils import math import os -from . import library, ops +from . import library, utils def append(context, path, obj_name): @@ -18,7 +18,7 @@ def append(context, path, obj_name): class ShoeLacing: label = "ShoeLacing(Base)" - def __init__(self, obj, vertices2d, settings: ops.ShoeLacingProps): + def __init__(self, obj, vertices2d, settings): self.base_obj = obj self.vertices2d = vertices2d self.settings = settings @@ -353,7 +353,7 @@ def get_top_points(self, context): center = self.calc_center_points(y, is_reversed) asset = library.knots[int(settings.knot_type)] - knots = ops.get_knot_list(context.scene, context) + knots = utils.get_knot_list(context.scene, context) is_local_object = (asset[1] == "") if asset[1] is None or (is_local_object and len(knots) == 0): return (left + center, right, True) diff --git a/lib/ops.py b/lib/ops.py index 68f7ace..76ebc79 100644 --- a/lib/ops.py +++ b/lib/ops.py @@ -19,15 +19,6 @@ def check_index(self, value): return value -def get_knot_list(scene, context): - settings = utils.get_settings(context) - items = [ - (knot.object.name, knot.object.name, "") - for i, knot in enumerate(settings.knots) if knot.object is not None - ] - return items - - class OBJECT_OT_TareminShoeLacesCreateCurve(bpy.types.Operator): bl_idname = 'taremin.shoelaces_create_curve' bl_label = 'カーブの生成' @@ -136,7 +127,7 @@ def set_index_right(self, value): options={'HIDDEN'} ) - knot: bpy.props.EnumProperty(items=get_knot_list) + knot: bpy.props.EnumProperty(items=utils.get_knot_list) # -------------------------------------------------------------------------- @@ -447,7 +438,7 @@ def draw(self, context): box = layout.box() box.prop(self, "knot_type") knot = library.knots[int(self.knot_type)] - knots = get_knot_list(context.scene, context) + knots = utils.get_knot_list(context.scene, context) if knot[1] == "" and len(knots) > 0: box.prop(self, "knot") box.prop(self, "is_reverse_spline_left") diff --git a/lib/utils.py b/lib/utils.py index b96c900..af6a790 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -5,3 +5,12 @@ def get_settings(context): def set_settings(context, value): context.scene.taremin_shoelace = value + + +def get_knot_list(scene, context): + settings = get_settings(context) + items = [ + (knot.object.name, knot.object.name, "") + for i, knot in enumerate(settings.knots) if knot.object is not None + ] + return items