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
+19 -21
View File
@@ -115,26 +115,24 @@ def get_schedule_predefined_types(self, context):
return CostSchedulesData.data["predefined_types"]
# TODO: unsafe?
def get_currencies(self, context):
return [
("USD", "USD", "Dollar"),
("EUR", "EUR", "Euro"),
("GBP", "GBP", "Pound"),
("AUD", "AUD", "Australian Dollar"),
("CAD", "CAD", "Canadian Dollar"),
("CHF", "CHF", "Swiss Franc"),
("CNY", "CNY", "Chinese Yuan"),
("HKD", "HKD", "Hong Kong Dollar"),
("JPY", "JPY", "Japanese Yen"),
("NZD", "NZD", "New Zealand Dollar"),
("SEK", "SEK", "Swedish Krona"),
("KRW", "KRW", "South Korean Won"),
("SGD", "SGD", "Singapore Dollar"),
("NOK", "NOK", "Norwegian Krone"),
("MAD", "MAD", "Moroccan Dirham"),
("CUSTOM", "Custom currency", "Custom"),
]
CURRENCIES_ENUM_ITEMS = (
("USD", "USD", "Dollar"),
("EUR", "EUR", "Euro"),
("GBP", "GBP", "Pound"),
("AUD", "AUD", "Australian Dollar"),
("CAD", "CAD", "Canadian Dollar"),
("CHF", "CHF", "Swiss Franc"),
("CNY", "CNY", "Chinese Yuan"),
("HKD", "HKD", "Hong Kong Dollar"),
("JPY", "JPY", "Japanese Yen"),
("NZD", "NZD", "New Zealand Dollar"),
("SEK", "SEK", "Swedish Krona"),
("KRW", "KRW", "South Korean Won"),
("SGD", "SGD", "Singapore Dollar"),
("NOK", "NOK", "Norwegian Krone"),
("MAD", "MAD", "Moroccan Dirham"),
("CUSTOM", "Custom currency", "Custom"),
)
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)
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(
name="Custom Currency", default="USD", description="Custom Currency in ISO 4217 format"
)
@@ -79,50 +79,48 @@ def get_property_template_type(self, context):
return PsetTemplatesData.data["property_template_type"]
# TODO: unsafe?
def get_template_type(self, context):
return [
(
"PSET_TYPEDRIVENONLY",
"Pset - IfcTypeObject",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"PSET_TYPEDRIVENOVERRIDE",
"Pset - IfcTypeObject - Override",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"PSET_OCCURRENCEDRIVEN",
"Pset - IfcObject",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.",
),
(
"PSET_PERFORMANCEDRIVEN",
"Pset - IfcPerformanceHistory",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.",
),
(
"QTO_TYPEDRIVENONLY",
"Qto - IfcTypeObject",
"The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"QTO_TYPEDRIVENOVERRIDE",
"Qto - IfcTypeObject - Override",
"The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.",
),
(
"QTO_OCCURRENCEDRIVEN",
"Qto - IfcObject",
"The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.",
),
(
"NOTDEFINED",
"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.",
),
]
TEMPLATE_TYPE_ENUM_ITEMS = (
(
"PSET_TYPEDRIVENONLY",
"Pset - IfcTypeObject",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"PSET_TYPEDRIVENOVERRIDE",
"Pset - IfcTypeObject - Override",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"PSET_OCCURRENCEDRIVEN",
"Pset - IfcObject",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.",
),
(
"PSET_PERFORMANCEDRIVEN",
"Pset - IfcPerformanceHistory",
"The property sets defined by this IfcPropertySetTemplate can only be assigned to IfcPerformanceHistory.",
),
(
"QTO_TYPEDRIVENONLY",
"Qto - IfcTypeObject",
"The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcTypeObject.",
),
(
"QTO_TYPEDRIVENOVERRIDE",
"Qto - IfcTypeObject - Override",
"The element quantity defined by this IfcPropertySetTemplate can be assigned to subtypes of IfcTypeObject and can be overridden by an element quantity with same name at subtypes of IfcObject.",
),
(
"QTO_OCCURRENCEDRIVEN",
"Qto - IfcObject",
"The element quantity defined by this IfcPropertySetTemplate can only be assigned to subtypes of IfcObject.",
),
(
"NOTDEFINED",
"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.",
),
)
class PsetTemplate(PropertyGroup):
@@ -139,7 +137,7 @@ class PsetTemplate(PropertyGroup):
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "Description"),
)
template_type: EnumProperty(
items=get_template_type,
items=TEMPLATE_TYPE_ENUM_ITEMS,
name="Template Type",
description=get_attribute_doc("IFC4", "IfcPropertySetTemplate", "TemplateType"),
)