Use static enum items instead of dynamic

This commit is contained in:
Andrej730
2024-11-01 14:13:08 +05:00
parent 1acf8f1ed8
commit 9c0256165e
2 changed files with 62 additions and 66 deletions
+3 -5
View File
@@ -115,9 +115,7 @@ def get_schedule_predefined_types(self, context):
return CostSchedulesData.data["predefined_types"] return CostSchedulesData.data["predefined_types"]
# TODO: unsafe? CURRENCIES_ENUM_ITEMS = (
def get_currencies(self, context):
return [
("USD", "USD", "Dollar"), ("USD", "USD", "Dollar"),
("EUR", "EUR", "Euro"), ("EUR", "EUR", "Euro"),
("GBP", "GBP", "Pound"), ("GBP", "GBP", "Pound"),
@@ -134,7 +132,7 @@ def get_currencies(self, context):
("NOK", "NOK", "Norwegian Krone"), ("NOK", "NOK", "Norwegian Krone"),
("MAD", "MAD", "Moroccan Dirham"), ("MAD", "MAD", "Moroccan Dirham"),
("CUSTOM", "Custom currency", "Custom"), ("CUSTOM", "Custom currency", "Custom"),
] )
class CostItem(PropertyGroup): class CostItem(PropertyGroup):
@@ -248,7 +246,7 @@ class BIMCostProperties(PropertyGroup):
) )
change_cost_item_parent: BoolProperty(name="Change Cost Item Parent", default=False, update=update_cost_item_parent) change_cost_item_parent: BoolProperty(name="Change Cost Item Parent", default=False, update=update_cost_item_parent)
show_cost_item_operators: BoolProperty(name="Show Cost Item Operators", default=False) show_cost_item_operators: BoolProperty(name="Show Cost Item Operators", default=False)
currency: EnumProperty(items=get_currencies, name="Currencies") currency: EnumProperty(items=CURRENCIES_ENUM_ITEMS, name="Currencies")
custom_currency: StringProperty( custom_currency: StringProperty(
name="Custom Currency", default="USD", description="Custom Currency in ISO 4217 format" name="Custom Currency", default="USD", description="Custom Currency in ISO 4217 format"
) )
@@ -79,9 +79,7 @@ def get_property_template_type(self, context):
return PsetTemplatesData.data["property_template_type"] return PsetTemplatesData.data["property_template_type"]
# TODO: unsafe? TEMPLATE_TYPE_ENUM_ITEMS = (
def get_template_type(self, context):
return [
( (
"PSET_TYPEDRIVENONLY", "PSET_TYPEDRIVENONLY",
"Pset - IfcTypeObject", "Pset - IfcTypeObject",
@@ -122,7 +120,7 @@ def get_template_type(self, context):
"Not defined", "Not defined",
"No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.", "No restriction provided, the property sets defined by this IfcPropertySetTemplate can be assigned to any entity, if not otherwise restricted by the ApplicableEntity attribute.",
), ),
] )
class PsetTemplate(PropertyGroup): class PsetTemplate(PropertyGroup):
@@ -139,7 +137,7 @@ class PsetTemplate(PropertyGroup):
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "Description"), description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "Description"),
) )
template_type: EnumProperty( template_type: EnumProperty(
items=get_template_type, items=TEMPLATE_TYPE_ENUM_ITEMS,
name="Template Type", name="Template Type",
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "TemplateType"), description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "TemplateType"),
) )