33import adsk .core
44import adsk .fusion
55
6- from src import Logging , gm
6+ from src import Logging
77from src .UI import IconPaths
8+ from src .DesignRuleChecks import DesignRuleChecks
89
910logger = Logging .getLogger ()
1011
1112
12- class DesignRule (TypedDict ):
13- name : str
14- calculation : Callable [[], float ]
15- max_value : float
16-
17-
1813class DesignCheckTab :
1914 designCheckTab : adsk .core .TabCommandInput
2015 designCheckTable : adsk .core .TableCommandInput
21- designRules : Dict [str , Any ] = {}
22- design_rules : List [DesignRule ]
16+ designRuleChecks : DesignRuleChecks
2317
2418 @Logging .logFailure
2519 def __init__ (self , args : adsk .core .CommandCreatedEventArgs ) -> None :
@@ -34,21 +28,9 @@ def __init__(self, args: adsk.core.CommandCreatedEventArgs) -> None:
3428 adsk .core .TablePresentationStyles .itemBorderTablePresentationStyle
3529 )
3630
37- # Define and add design rules to the table
38- self .design_rules = [
39- {
40- "name" : "Design Height" ,
41- "calculation" : self .fusion_design_height ,
42- "max_value" : 106.0 , # cm
43- },
44- {
45- "name" : "Design Perimeter" ,
46- "calculation" : self .fusion_design_perimeter ,
47- "max_value" : 304.0 , # cm
48- },
49- ]
31+ self .designRuleChecks = DesignRuleChecks ()
5032
51- for i , rule in enumerate (self .design_rules ):
33+ for i , rule in enumerate (self .designRuleChecks . getDesignRules () ):
5234 calculation = rule ["calculation" ]
5335 max_value : float = rule ["max_value" ]
5436 value : float = calculation ()
@@ -81,19 +63,3 @@ def isVisible(self, value: bool) -> None:
8163 @property
8264 def isActive (self ) -> bool :
8365 return self .designCheckTab .isActive or False
84-
85- @Logging .logFailure
86- def fusion_design_height (self ) -> float :
87- design = adsk .fusion .Design .cast (gm .app .activeProduct )
88- if design :
89- overall_bounding_box = design .rootComponent .orientedMinimumBoundingBox
90- return float (overall_bounding_box .width )
91- return 0.0
92-
93- @Logging .logFailure
94- def fusion_design_perimeter (self ) -> float :
95- design = adsk .fusion .Design .cast (gm .app .activeProduct )
96- if design :
97- overall_bounding_box = design .rootComponent .orientedMinimumBoundingBox
98- return float (2 * (overall_bounding_box .height + overall_bounding_box .length ))
99- return 0.0
0 commit comments