diff --git a/src/blenderbim/blenderbim/bim/module/constraint/prop.py b/src/blenderbim/blenderbim/bim/module/constraint/prop.py index aea987c4a7..003164345e 100644 --- a/src/blenderbim/blenderbim/bim/module/constraint/prop.py +++ b/src/blenderbim/blenderbim/bim/module/constraint/prop.py @@ -17,7 +17,7 @@ # along with BlenderBIM Add-on. If not, see . import bpy -from blenderbim.bim.prop import StrProperty, Attribute +from blenderbim.bim.prop import StrProperty, Attribute, get_ifc_entity_description from bpy.types import PropertyGroup from bpy.props import ( PointerProperty, @@ -31,6 +31,10 @@ from bpy.props import ( ) +def get_available_constraint_types(self, context): + return [(c, c, get_ifc_entity_description(c)) for c in ["IfcObjective"]] + + class Constraint(PropertyGroup): name: StringProperty(name="Name") ifc_definition_id: IntProperty(name="IFC Definition ID") @@ -46,6 +50,4 @@ class BIMConstraintProperties(PropertyGroup): class BIMObjectConstraintProperties(PropertyGroup): is_adding: StringProperty(name="Is Adding") - available_constraint_types: EnumProperty( - items=[(c, c, "") for c in ["IfcObjective"]], name="Available Constraint Types" - ) + available_constraint_types: EnumProperty(items=get_available_constraint_types, name="Available Constraint Types") diff --git a/src/blenderbim/blenderbim/bim/module/material/data.py b/src/blenderbim/blenderbim/bim/module/material/data.py index 78ef924562..37171d2867 100644 --- a/src/blenderbim/blenderbim/bim/module/material/data.py +++ b/src/blenderbim/blenderbim/bim/module/material/data.py @@ -21,6 +21,7 @@ import bpy import ifcopenshell import ifcopenshell.util.schema import blenderbim.tool as tool +from blenderbim.bim.prop import get_ifc_entity_description def refresh(): @@ -67,7 +68,7 @@ class MaterialsData: ] if tool.Ifc.get_schema() == "IFC2X3": material_types = ["IfcMaterial", "IfcMaterialLayerSet", "IfcMaterialList"] - return [(m, m, "") for m in material_types] + return [(m, m, get_ifc_entity_description(m)) for m in material_types] class ObjectMaterialData: diff --git a/src/blenderbim/blenderbim/bim/module/material/prop.py b/src/blenderbim/blenderbim/bim/module/material/prop.py index 8f400ab07f..cd9e2f4e6f 100644 --- a/src/blenderbim/blenderbim/bim/module/material/prop.py +++ b/src/blenderbim/blenderbim/bim/module/material/prop.py @@ -20,7 +20,7 @@ import bpy from ifcopenshell.api.material.data import Data from blenderbim.bim.module.material.data import MaterialsData, ObjectMaterialData from blenderbim.bim.ifc import IfcStore -from blenderbim.bim.prop import StrProperty, Attribute +from blenderbim.bim.prop import StrProperty, Attribute, get_ifc_entity_description from bpy.types import PropertyGroup from bpy.props import ( PointerProperty, @@ -81,7 +81,7 @@ def get_materials(self, context): return ObjectMaterialData.data["materials"] -def getMaterialTypes(self, context): +def get_object_material_types(self, context): global materialtypes_enum if len(materialtypes_enum) == 0 and IfcStore.get_file(): material_types = [ @@ -96,7 +96,7 @@ def getMaterialTypes(self, context): if IfcStore.get_file().schema == "IFC2X3": material_types = ["IfcMaterial", "IfcMaterialLayerSet", "IfcMaterialLayerSetUsage", "IfcMaterialList"] materialtypes_enum.clear() - materialtypes_enum = [(m, m, "") for m in material_types] + materialtypes_enum = [(m, m, get_ifc_entity_description(m)) for m in material_types] return materialtypes_enum @@ -122,7 +122,7 @@ class BIMMaterialProperties(PropertyGroup): class BIMObjectMaterialProperties(PropertyGroup): - material_type: EnumProperty(items=getMaterialTypes, name="Material Type") + material_type: EnumProperty(items=get_object_material_types, name="Material Type") material: EnumProperty(items=get_materials, name="Material") is_editing: BoolProperty(name="Is Editing", default=False) material_set_usage_attributes: CollectionProperty(name="Material Set Usage Attributes", type=Attribute) diff --git a/src/blenderbim/blenderbim/bim/module/owner/prop.py b/src/blenderbim/blenderbim/bim/module/owner/prop.py index c1a2e65915..239c69dbf6 100644 --- a/src/blenderbim/blenderbim/bim/module/owner/prop.py +++ b/src/blenderbim/blenderbim/bim/module/owner/prop.py @@ -17,7 +17,7 @@ # along with BlenderBIM Add-on. If not, see . import bpy -from blenderbim.bim.prop import StrProperty, Attribute +from blenderbim.bim.prop import StrProperty, Attribute, get_ifc_entity_description from blenderbim.bim.module.owner.data import OwnerData, ActorData, ObjectActorData from bpy.types import PropertyGroup from bpy.props import ( @@ -64,6 +64,21 @@ def update_actor_class(self, context): ActorData.data["actors"] = ActorData.actors() +def get_actor_class_enum(self, context): + return [ + ("IfcActor", "Actor", get_ifc_entity_description("IfcActor")), + ("IfcOccupant", "Occupant", get_ifc_entity_description("IfcOccupant")), + ] + + +def get_actor_type_enum(self, context): + return [ + ("IfcPerson", "Person", get_ifc_entity_description("IfcPerson")), + ("IfcOrganization", "Organisation", get_ifc_entity_description("IfcOrganization")), + ("IfcPersonAndOrganization", "User", get_ifc_entity_description("IfcPersonAndOrganization")), + ] + + class BIMOwnerProperties(PropertyGroup): active_person_id: IntProperty(name="Active Person Id") person_attributes: CollectionProperty(name="Person Attributes", type=Attribute) @@ -87,16 +102,12 @@ class BIMOwnerProperties(PropertyGroup): active_actor_id: IntProperty(name="Active Actor Id") actor_attributes: CollectionProperty(name="Actor Attributes", type=Attribute) actor_class: EnumProperty( - items=(("IfcActor", "Actor", ""), ("IfcOccupant", "Occupant", "")), + items=get_actor_class_enum, name="Actor Type", update=update_actor_class, ) actor_type: EnumProperty( - items=( - ("IfcPerson", "Person", ""), - ("IfcOrganization", "Organisation", ""), - ("IfcPersonAndOrganization", "User", ""), - ), + items=get_actor_type_enum, name="Actor Type", update=update_actor_type, ) diff --git a/src/blenderbim/blenderbim/bim/module/structural/prop.py b/src/blenderbim/blenderbim/bim/module/structural/prop.py index 38fb4e571a..3397157687 100644 --- a/src/blenderbim/blenderbim/bim/module/structural/prop.py +++ b/src/blenderbim/blenderbim/bim/module/structural/prop.py @@ -19,7 +19,7 @@ import bpy from blenderbim.bim.ifc import IfcStore from math import radians -from blenderbim.bim.prop import StrProperty, Attribute +from blenderbim.bim.prop import StrProperty, Attribute, get_ifc_entity_description from ifcopenshell.api.structural.data import Data from bpy.types import PropertyGroup from bpy.props import ( @@ -84,20 +84,24 @@ def getApplicableStructuralLoads(self, context): return applicablestructuralloads_enum -def getStructuralLoadTypes(self, context): +def get_structural_load_types(self, context): global structuralloadtypes_enum file = IfcStore.get_file() if len(structuralloadtypes_enum) < 1 and file: declaration = IfcStore.get_schema().declaration_by_name("IfcStructuralLoadStatic") - structuralloadtypes_enum.extend([(d.name(), d.name(), "") for d in declaration.subtypes()]) + structuralloadtypes_enum.extend( + [(d.name(), d.name(), get_ifc_entity_description(d.name())) for d in declaration.subtypes()] + ) return structuralloadtypes_enum -def getBoundaryConditionTypes(self, context): +def get_boundary_condition_types(self, context): file = IfcStore.get_file() if file: declaration = IfcStore.get_schema().declaration_by_name("IfcBoundaryCondition") - boundaryconditiontypes_enum = [(d.name(), d.name(), "") for d in declaration.subtypes()] + boundaryconditiontypes_enum = [ + (d.name(), d.name(), get_ifc_entity_description(d.name())) for d in declaration.subtypes() + ] return boundaryconditiontypes_enum return [] @@ -177,7 +181,7 @@ class BIMStructuralProperties(PropertyGroup): active_structural_load_index: IntProperty(name="Active Structural Load Index") active_structural_load_id: IntProperty(name="Active Structural Load Id") is_editing_loads: BoolProperty(name="Is Editing Loads", default=False) - structural_load_types: EnumProperty(items=getStructuralLoadTypes, name="Structural Load Types") + structural_load_types: EnumProperty(items=get_structural_load_types, name="Structural Load Types") structural_load_attributes: CollectionProperty(name="Structural Load Attributes", type=Attribute) filtered_structural_loads: BoolProperty(name="Filtered Structural Loads", default=False) @@ -185,7 +189,7 @@ class BIMStructuralProperties(PropertyGroup): active_boundary_condition_index: IntProperty(name="Active Boundary Condition Index") active_boundary_condition_id: IntProperty(name="Active Boundary Condition Id") is_editing_boundary_conditions: BoolProperty(name="Is Editing Boundary Conditions", default=False) - boundary_condition_types: EnumProperty(items=getBoundaryConditionTypes, name="Boundary Condition Types") + boundary_condition_types: EnumProperty(items=get_boundary_condition_types, name="Boundary Condition Types") boundary_condition_attributes: CollectionProperty(name="Boundary Condition Attributes", type=Attribute) filtered_boundary_conditions: BoolProperty(name="Filtered Boundary Conditions", default=False) diff --git a/src/blenderbim/blenderbim/bim/module/style/data.py b/src/blenderbim/blenderbim/bim/module/style/data.py index 9f6d768785..df9da618a1 100644 --- a/src/blenderbim/blenderbim/bim/module/style/data.py +++ b/src/blenderbim/blenderbim/bim/module/style/data.py @@ -19,6 +19,7 @@ import bpy import blenderbim.tool as tool import ifcopenshell +from blenderbim.bim.prop import get_ifc_entity_description def refresh(): @@ -38,7 +39,7 @@ class StylesData: def style_types(cls): declaration = tool.Ifc.schema().declaration_by_name("IfcPresentationStyle") declarations = ifcopenshell.util.schema.get_subtypes(declaration) - return [(c, c, "") for c in sorted([d.name() for d in declarations])] + return [(c, c, get_ifc_entity_description(c)) for c in sorted([d.name() for d in declarations])] @classmethod def total_styles(cls): diff --git a/src/blenderbim/blenderbim/bim/module/system/data.py b/src/blenderbim/blenderbim/bim/module/system/data.py index c9c00dbf9d..244972f75d 100644 --- a/src/blenderbim/blenderbim/bim/module/system/data.py +++ b/src/blenderbim/blenderbim/bim/module/system/data.py @@ -20,6 +20,7 @@ import bpy import ifcopenshell import ifcopenshell.util.schema import blenderbim.tool as tool +from blenderbim.bim.prop import get_ifc_entity_description def refresh(): @@ -46,7 +47,7 @@ class SystemData: declarations = ifcopenshell.util.schema.get_subtypes(declaration) # We're only interested in systems for services. Not sure why IFC groups these together. return [ - (c, c, "") + (c, c, get_ifc_entity_description(c)) for c in sorted([d.name() for d in declarations]) if c not in ("IfcZone", "IfcStructuralAnalysisModel") ] diff --git a/src/blenderbim/blenderbim/bim/module/type/data.py b/src/blenderbim/blenderbim/bim/module/type/data.py index 0115153268..0a5470479f 100644 --- a/src/blenderbim/blenderbim/bim/module/type/data.py +++ b/src/blenderbim/blenderbim/bim/module/type/data.py @@ -20,6 +20,7 @@ import bpy import ifcopenshell.util.type import ifcopenshell.util.element import blenderbim.tool as tool +from blenderbim.bim.prop import get_ifc_entity_description def refresh(): @@ -54,7 +55,7 @@ class TypeData: if not element: return [] types = ifcopenshell.util.type.get_applicable_types(element.is_a(), schema=tool.Ifc.get_schema()) - results.extend((t, t, "") for t in types) + results.extend((t, t, get_ifc_entity_description(t)) for t in types) return results @classmethod diff --git a/src/blenderbim/blenderbim/bim/module/unit/data.py b/src/blenderbim/blenderbim/bim/module/unit/data.py index 9fa647e08c..7b75b59eac 100644 --- a/src/blenderbim/blenderbim/bim/module/unit/data.py +++ b/src/blenderbim/blenderbim/bim/module/unit/data.py @@ -21,6 +21,7 @@ import ifcopenshell.util.unit import ifcopenshell.util.schema import ifcopenshell.util.attribute import blenderbim.tool as tool +from blenderbim.bim.prop import get_ifc_entity_description def refresh(): @@ -44,7 +45,7 @@ class UnitsData: @classmethod def unit_classes(cls): declarations = ifcopenshell.util.schema.get_subtypes(tool.Ifc.schema().declaration_by_name("IfcNamedUnit")) - results = [(c, c, "") for c in sorted([d.name() for d in declarations])] + results = [(c, c, get_ifc_entity_description(c)) for c in sorted([d.name() for d in declarations])] results.extend([("IfcDerivedUnit", "IfcDerivedUnit", ""), ("IfcMonetaryUnit", "IfcMonetaryUnit", "")]) return results diff --git a/src/blenderbim/blenderbim/bim/prop.py b/src/blenderbim/blenderbim/bim/prop.py index b2c9170361..4925c4ff1e 100644 --- a/src/blenderbim/blenderbim/bim/prop.py +++ b/src/blenderbim/blenderbim/bim/prop.py @@ -128,7 +128,19 @@ def get_predefined_type_description(entity, predefined_type): return get_predefined_type_doc(schema, entity, predefined_type) -def getAttributeEnumValues(prop, context): +def get_attribute_description(entity, attribute): + schema = tool.Ifc.get_schema() + if schema is not None: + return get_attribute_doc(schema, entity, attribute) + + +def get_property_set_description(pset): + schema = tool.Ifc.get_schema() + if schema is not None: + return get_property_set_doc(schema, pset) + + +def get_attribute_enum_values(prop, context): # Support weird buildingSMART dictionary mappings which behave like enums items = [] data = json.loads(prop.enum_items) @@ -200,7 +212,7 @@ class ObjProperty(PropertyGroup): obj: bpy.props.PointerProperty(type=bpy.types.Object) -def updateAttributeValue(self, context): +def update_attribute_value(self, context): value_name = self.get_value_name() if value_name: value_names = [value_name] @@ -217,12 +229,12 @@ def updateAttributeValue(self, context): class Attribute(PropertyGroup): name: StringProperty(name="Name") data_type: StringProperty(name="Data Type") - string_value: StringProperty(name="Value", update=updateAttributeValue) - bool_value: BoolProperty(name="Value", update=updateAttributeValue) - int_value: IntProperty(name="Value", update=updateAttributeValue) - float_value: FloatProperty(name="Value", update=updateAttributeValue) + string_value: StringProperty(name="Value", update=update_attribute_value) + bool_value: BoolProperty(name="Value", update=update_attribute_value) + int_value: IntProperty(name="Value", update=update_attribute_value) + float_value: FloatProperty(name="Value", update=update_attribute_value) enum_items: StringProperty(name="Value") - enum_value: EnumProperty(items=getAttributeEnumValues, name="Value", update=updateAttributeValue) + enum_value: EnumProperty(items=get_attribute_enum_values, name="Value", update=update_attribute_value) is_null: BoolProperty(name="Is Null") is_optional: BoolProperty(name="Is Optional") is_uri: BoolProperty(name="Is Uri", default=False)