diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index d6f4ea17c4..b8d9c5172c 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -30,6 +30,7 @@ if bpy is not None: "owner": None, "project": None, "pset": None, + "pset_template": None, "qto": None, "search": None, "spatial": None, @@ -97,12 +98,6 @@ if bpy is not None: operator.SelectSmartGroup, operator.LoadSmartGroupsForActiveClashSet, operator.OpenUpstream, - operator.AddPropertySetTemplate, - operator.RemovePropertySetTemplate, - operator.EditPropertySetTemplate, - operator.SavePropertySetTemplate, - operator.AddPropertyTemplate, - operator.RemovePropertyTemplate, operator.AddSectionPlane, operator.RemoveSectionPlane, operator.ReloadIfcFile, @@ -154,8 +149,6 @@ if bpy is not None: prop.StrProperty, prop.Attribute, prop.Variable, - prop.PropertySetTemplate, - prop.PropertyTemplate, prop.ClashSource, prop.ClashSet, prop.SmartClashGroup, @@ -183,7 +176,6 @@ if bpy is not None: ui.BIM_PT_drawings, ui.BIM_PT_schedules, ui.BIM_PT_sheets, - ui.BIM_PT_psets, ui.BIM_PT_ifcclash, ui.BIM_PT_library, ui.BIM_PT_presentation_layers, diff --git a/src/ifcblenderexport/blenderbim/bim/module/pset_template/__init__.py b/src/ifcblenderexport/blenderbim/bim/module/pset_template/__init__.py new file mode 100644 index 0000000000..ca1547f40e --- /dev/null +++ b/src/ifcblenderexport/blenderbim/bim/module/pset_template/__init__.py @@ -0,0 +1,23 @@ +import bpy +from . import ui, prop, operator + +classes = ( + operator.AddPropertySetTemplate, + operator.RemovePropertySetTemplate, + operator.EditPropertySetTemplate, + operator.SavePropertySetTemplate, + operator.AddPropertyTemplate, + operator.RemovePropertyTemplate, + prop.PropertySetTemplate, + prop.PropertyTemplate, + prop.BIMPsetTemplateProperties, + ui.BIM_PT_pset_template, +) + + +def register(): + bpy.types.Scene.BIMPsetTemplateProperties = bpy.props.PointerProperty(type=prop.BIMPsetTemplateProperties) + + +def unregister(): + del bpy.types.Scene.BIMPsetTemplateProperties diff --git a/src/ifcblenderexport/blenderbim/bim/module/pset_template/operator.py b/src/ifcblenderexport/blenderbim/bim/module/pset_template/operator.py new file mode 100644 index 0000000000..824bcc1f27 --- /dev/null +++ b/src/ifcblenderexport/blenderbim/bim/module/pset_template/operator.py @@ -0,0 +1,127 @@ +import bpy +import ifcopenshell +from blenderbim.bim.module.pset_template.prop import refreshPropertySetTemplates +from blenderbim.bim.ifc import IfcStore + + +class AddPropertySetTemplate(bpy.types.Operator): + bl_idname = "bim.add_property_set_template" + bl_label = "Add Property Set Template" + + def execute(self, context): + props = context.scene.BIMPsetTemplateProperties + props.active_property_set_template.global_id = "" + props.active_property_set_template.name = "New_Pset" + props.active_property_set_template.description = "" + props.active_property_set_template.template_type = "PSET_TYPEDRIVENONLY" + props.active_property_set_template.applicable_entity = "IfcTypeObject" + while len(props.property_templates) > 0: + props.property_templates.remove(0) + return {"FINISHED"} + + +class RemovePropertySetTemplate(bpy.types.Operator): + bl_idname = "bim.remove_property_set_template" + bl_label = "Remove Property Set Template" + + def execute(self, context): + props = context.scene.BIMPsetTemplateProperties + template = IfcStore.pset_template_file.by_guid(props.property_set_templates) + IfcStore.pset_template_file.remove(template) + IfcStore.pset_template_file.write(IfcStore.pset_template_path) + refreshPropertySetTemplates(self, context) + return {"FINISHED"} + + +class EditPropertySetTemplate(bpy.types.Operator): + bl_idname = "bim.edit_property_set_template" + bl_label = "Edit Property Set Template" + + def execute(self, context): + props = context.scene.BIMPsetTemplateProperties + template = IfcStore.pset_template_file.by_guid(props.property_set_templates) + props.active_property_set_template.global_id = template.GlobalId + props.active_property_set_template.name = template.Name + props.active_property_set_template.description = template.Description + props.active_property_set_template.template_type = template.TemplateType + props.active_property_set_template.applicable_entity = template.ApplicableEntity + + while len(props.property_templates) > 0: + props.property_templates.remove(0) + + if template.HasPropertyTemplates: + for property_template in template.HasPropertyTemplates: + if not property_template.is_a("IfcSimplePropertyTemplate"): + continue + new = props.property_templates.add() + new.global_id = property_template.GlobalId + new.name = property_template.Name + new.description = property_template.Description + new.primary_measure_type = property_template.PrimaryMeasureType + return {"FINISHED"} + + +class SavePropertySetTemplate(bpy.types.Operator): + bl_idname = "bim.save_property_set_template" + bl_label = "Save Property Set Template" + + def execute(self, context): + props = context.scene.BIMPsetTemplateProperties + blender_property_set_template = props.active_property_set_template + if blender_property_set_template.global_id: + template = IfcStore.pset_template_file.by_guid(blender_property_set_template.global_id) + else: + template = IfcStore.pset_template_file.createIfcPropertySetTemplate() + template.GlobalId = ifcopenshell.guid.new() + template.Name = blender_property_set_template.name + template.Description = blender_property_set_template.description + template.TemplateType = blender_property_set_template.template_type + template.ApplicableEntity = blender_property_set_template.applicable_entity + + saved_global_ids = [] + + for blender_property_template in props.property_templates: + if blender_property_template.global_id: + property_template = IfcStore.pset_template_file.by_guid(blender_property_template.global_id) + else: + property_template = IfcStore.pset_template_file.createIfcSimplePropertyTemplate() + property_template.GlobalId = ifcopenshell.guid.new() + if template.HasPropertyTemplates: + has_property_templates = list(template.HasPropertyTemplates) + else: + has_property_templates = [] + has_property_templates.append(property_template) + template.HasPropertyTemplates = has_property_templates + property_template.Name = blender_property_template.name + property_template.Description = blender_property_template.description + property_template.PrimaryMeasureType = blender_property_template.primary_measure_type + property_template.TemplateType = "P_SINGLEVALUE" + property_template.AccessState = "READWRITE" + saved_global_ids.append(property_template.GlobalId) + + for element in template.HasPropertyTemplates: + if element.GlobalId not in saved_global_ids: + IfcStore.pset_template_file.remove(element) + + IfcStore.pset_template_file.write(IfcStore.pset_template_path) + refreshPropertySetTemplates(self, context) + return {"FINISHED"} + + +class AddPropertyTemplate(bpy.types.Operator): + bl_idname = "bim.add_property_template" + bl_label = "Add Property Template" + + def execute(self, context): + context.scene.BIMPsetTemplateProperties.property_templates.add() + return {"FINISHED"} + + +class RemovePropertyTemplate(bpy.types.Operator): + bl_idname = "bim.remove_property_template" + bl_label = "Remove Property Template" + index: bpy.props.IntProperty() + + def execute(self, context): + bpy.context.scene.BIMPsetTemplateProperties.property_templates.remove(self.index) + return {"FINISHED"} diff --git a/src/ifcblenderexport/blenderbim/bim/module/pset_template/prop.py b/src/ifcblenderexport/blenderbim/bim/module/pset_template/prop.py new file mode 100644 index 0000000000..c2c5690d6c --- /dev/null +++ b/src/ifcblenderexport/blenderbim/bim/module/pset_template/prop.py @@ -0,0 +1,229 @@ +import os +import bpy +import ifcopenshell +from blenderbim.bim.prop import StrProperty, Attribute +from blenderbim.bim.ifc import IfcStore +from bpy.types import PropertyGroup +from bpy.props import ( + PointerProperty, + StringProperty, + EnumProperty, + BoolProperty, + IntProperty, + FloatProperty, + FloatVectorProperty, + CollectionProperty, +) + + +psettemplatefiles_enum = [] +propertysettemplates_enum = [] + + +def refreshPropertySetTemplates(self, context): + global propertysettemplates_enum + propertysettemplates_enum.clear() + getPropertySetTemplates(self, context) + + +def getPsetTemplateFiles(self, context): + global psettemplatefiles_enum + if len(psettemplatefiles_enum) < 1: + files = os.listdir(os.path.join(context.scene.BIMProperties.data_dir, "pset")) + psettemplatefiles_enum.extend([(f.replace(".ifc", ""), f.replace(".ifc", ""), "") for f in files]) + return psettemplatefiles_enum + + +def getPropertySetTemplates(self, context): + global propertysettemplates_enum + if len(propertysettemplates_enum) < 1: + IfcStore.pset_template_path = os.path.join( + context.scene.BIMProperties.data_dir, "pset", context.scene.BIMPsetTemplateProperties.pset_template_files + ".ifc" + ) + IfcStore.pset_template_file = ifcopenshell.open(IfcStore.pset_template_path) + templates = IfcStore.pset_template_file.by_type("IfcPropertySetTemplate") + propertysettemplates_enum.extend([(t.GlobalId, t.Name, "") for t in templates]) + return propertysettemplates_enum + + +class PropertySetTemplate(PropertyGroup): + global_id: StringProperty(name="Global ID") + name: StringProperty(name="Name") + description: StringProperty(name="Description") + template_type: EnumProperty( + 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.", + ), + ], + name="Template Type", + ) + applicable_entity: StringProperty(name="Applicable Entity") + + +class PropertyTemplate(PropertyGroup): + global_id: StringProperty(name="Global ID") + name: StringProperty(name="Name") + description: StringProperty(name="Description") + primary_measure_type: EnumProperty( + items=[ + (x, x, "") + for x in [ + "IfcInteger", + "IfcReal", + "IfcBoolean", + "IfcIdentifier", + "IfcText", + "IfcLabel", + "IfcLogical", + "IfcDateTime", + "IfcDate", + "IfcTime", + "IfcDuration", + "IfcTimeStamp", + "IfcPositiveInteger", + "IfcBinary", + "IfcVolumeMeasure", + "IfcTimeMeasure", + "IfcThermodynamicTemperatureMeasure", + "IfcSolidAngleMeasure", + "IfcPositiveRatioMeasure", + "IfcRatioMeasure", + "IfcPositivePlaneAngleMeasure", + "IfcPlaneAngleMeasure", + "IfcParameterValue", + "IfcNumericMeasure", + "IfcMassMeasure", + "IfcPositiveLengthMeasure", + "IfcLengthMeasure", + "IfcElectricCurrentMeasure", + "IfcDescriptiveMeasure", + "IfcCountMeasure", + "IfcContextDependentMeasure", + "IfcAreaMeasure", + "IfcAmountOfSubstanceMeasure", + "IfcLuminousIntensityMeasure", + "IfcNormalisedRatioMeasure", + "IfcComplexNumber", + "IfcNonNegativeLengthMeasure", + "IfcAbsorbedDoseMeasure", + "IfcAccelerationMeasure", + "IfcAngularVelocityMeasure", + "IfcAreaDensityMeasure", + "IfcCompoundPlaneAngleMeasure", + "IfcCurvatureMeasure", + "IfcDoseEquivalentMeasure", + "IfcDynamicViscosityMeasure", + "IfcElectricCapacitanceMeasure", + "IfcElectricChargeMeasure", + "IfcElectricConductanceMeasure", + "IfcElectricResistanceMeasure", + "IfcElectricVoltageMeasure", + "IfcEnergyMeasure", + "IfcForceMeasure", + "IfcFrequencyMeasure", + "IfcHeatFluxDensityMeasure", + "IfcHeatingValueMeasure", + "IfcIlluminanceMeasure", + "IfcInductanceMeasure", + "IfcIntegerCountRateMeasure", + "IfcIonConcentrationMeasure", + "IfcIsothermalMoistureCapacityMeasure", + "IfcKinematicViscosityMeasure", + "IfcLinearForceMeasure", + "IfcLinearMomentMeasure", + "IfcLinearStiffnessMeasure", + "IfcLinearVelocityMeasure", + "IfcLuminousFluxMeasure", + "IfcLuminousIntensityDistributionMeasure", + "IfcMagneticFluxDensityMeasure", + "IfcMagneticFluxMeasure", + "IfcMassDensityMeasure", + "IfcMassFlowRateMeasure", + "IfcMassPerLengthMeasure", + "IfcModulusOfElasticityMeasure", + "IfcModulusOfLinearSubgradeReactionMeasure", + "IfcModulusOfRotationalSubgradeReactionMeasure", + "IfcModulusOfSubgradeReactionMeasure", + "IfcMoistureDiffusivityMeasure", + "IfcMolecularWeightMeasure", + "IfcMomentOfInertiaMeasure", + "IfcMonetaryMeasure", + "IfcPHMeasure", + "IfcPlanarForceMeasure", + "IfcPowerMeasure", + "IfcPressureMeasure", + "IfcRadioActivityMeasure", + "IfcRotationalFrequencyMeasure", + "IfcRotationalMassMeasure", + "IfcRotationalStiffnessMeasure", + "IfcSectionModulusMeasure", + "IfcSectionalAreaIntegralMeasure", + "IfcShearModulusMeasure", + "IfcSoundPowerLevelMeasure", + "IfcSoundPowerMeasure", + "IfcSoundPressureLevelMeasure", + "IfcSoundPressureMeasure", + "IfcSpecificHeatCapacityMeasure", + "IfcTemperatureGradientMeasure", + "IfcTemperatureRateOfChangeMeasure", + "IfcThermalAdmittanceMeasure", + "IfcThermalConductivityMeasure", + "IfcThermalExpansionCoefficientMeasure", + "IfcThermalResistanceMeasure", + "IfcThermalTransmittanceMeasure", + "IfcTorqueMeasure", + "IfcVaporPermeabilityMeasure", + "IfcVolumetricFlowRateMeasure", + "IfcWarpingConstantMeasure", + "IfcWarpingMomentMeasure", + ] + ], + name="Primary Measure Type", + ) + + +class BIMPsetTemplateProperties(PropertyGroup): + pset_template_files: EnumProperty( + items=getPsetTemplateFiles, name="Pset Template Files", update=refreshPropertySetTemplates + ) + property_set_templates: EnumProperty(items=getPropertySetTemplates, name="Pset Template Files") + active_property_set_template: PointerProperty(type=PropertySetTemplate) + property_templates: CollectionProperty(name="Property Templates", type=PropertyTemplate) diff --git a/src/ifcblenderexport/blenderbim/bim/module/pset_template/ui.py b/src/ifcblenderexport/blenderbim/bim/module/pset_template/ui.py new file mode 100644 index 0000000000..881b175a0c --- /dev/null +++ b/src/ifcblenderexport/blenderbim/bim/module/pset_template/ui.py @@ -0,0 +1,47 @@ +import bpy +from bpy.types import Panel + + +class BIM_PT_pset_template(Panel): + bl_label = "IFC Property Set Templates" + bl_idname = "BIM_PT_pset_template" + bl_options = {"DEFAULT_CLOSED"} + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "scene" + + def draw(self, context): + layout = self.layout + props = context.scene.BIMPsetTemplateProperties + + row = layout.row(align=True) + row.prop(props, "pset_template_files", text="") + + row = layout.row(align=True) + row.prop(props, "property_set_templates", text="") + row.operator("bim.add_property_set_template", text="", icon="ADD") + row.operator("bim.remove_property_set_template", text="", icon="PANEL_CLOSE") + row.operator("bim.edit_property_set_template", text="", icon="IMPORT") + row.operator("bim.save_property_set_template", text="", icon="EXPORT") + + row = layout.row(align=True) + row.prop(props.active_property_set_template, "name") + row = layout.row(align=True) + row.prop(props.active_property_set_template, "description") + row = layout.row(align=True) + row.prop(props.active_property_set_template, "template_type") + row = layout.row(align=True) + row.prop(props.active_property_set_template, "applicable_entity") + + layout.label(text="Property Templates:") + + row = layout.row(align=True) + row.operator("bim.add_property_template") + + for index, template in enumerate(props.property_templates): + row = layout.row(align=True) + row.prop(template, "name", text="") + row.prop(template, "description", text="") + row.prop(template, "primary_measure_type", text="") + row.operator("bim.remove_property_template", icon="X", text="").index = index + diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index a7c8507d2b..5daa1c0888 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1321,129 +1321,6 @@ class CopyAttributeToSelection(bpy.types.Operator): return self.applicable_attributes_cache[ifc_class] -class AddPropertySetTemplate(bpy.types.Operator): - bl_idname = "bim.add_property_set_template" - bl_label = "Add Property Set Template" - - def execute(self, context): - context.scene.BIMProperties.active_property_set_template.global_id = "" - context.scene.BIMProperties.active_property_set_template.name = "New_Pset" - context.scene.BIMProperties.active_property_set_template.description = "" - context.scene.BIMProperties.active_property_set_template.template_type = "PSET_TYPEDRIVENONLY" - context.scene.BIMProperties.active_property_set_template.applicable_entity = "IfcTypeObject" - while len(bpy.context.scene.BIMProperties.property_templates) > 0: - bpy.context.scene.BIMProperties.property_templates.remove(0) - return {"FINISHED"} - - -class RemovePropertySetTemplate(bpy.types.Operator): - bl_idname = "bim.remove_property_set_template" - bl_label = "Remove Property Set Template" - - def execute(self, context): - template = ifc.IfcStore.pset_template_file.by_guid(context.scene.BIMProperties.property_set_templates) - ifc.IfcStore.pset_template_file.remove(template) - ifc.IfcStore.pset_template_file.write(ifc.IfcStore.pset_template_path) - from . import prop - - prop.refreshPropertySetTemplates(self, context) - return {"FINISHED"} - - -class EditPropertySetTemplate(bpy.types.Operator): - bl_idname = "bim.edit_property_set_template" - bl_label = "Edit Property Set Template" - - def execute(self, context): - template = ifc.IfcStore.pset_template_file.by_guid(context.scene.BIMProperties.property_set_templates) - context.scene.BIMProperties.active_property_set_template.global_id = template.GlobalId - context.scene.BIMProperties.active_property_set_template.name = template.Name - context.scene.BIMProperties.active_property_set_template.description = template.Description - context.scene.BIMProperties.active_property_set_template.template_type = template.TemplateType - context.scene.BIMProperties.active_property_set_template.applicable_entity = template.ApplicableEntity - - while len(bpy.context.scene.BIMProperties.property_templates) > 0: - bpy.context.scene.BIMProperties.property_templates.remove(0) - - if template.HasPropertyTemplates: - for property_template in template.HasPropertyTemplates: - if not property_template.is_a("IfcSimplePropertyTemplate"): - continue - new = context.scene.BIMProperties.property_templates.add() - new.global_id = property_template.GlobalId - new.name = property_template.Name - new.description = property_template.Description - new.primary_measure_type = property_template.PrimaryMeasureType - return {"FINISHED"} - - -class SavePropertySetTemplate(bpy.types.Operator): - bl_idname = "bim.save_property_set_template" - bl_label = "Save Property Set Template" - - def execute(self, context): - blender_property_set_template = context.scene.BIMProperties.active_property_set_template - if blender_property_set_template.global_id: - template = ifc.IfcStore.pset_template_file.by_guid(blender_property_set_template.global_id) - else: - template = ifc.IfcStore.pset_template_file.createIfcPropertySetTemplate() - template.GlobalId = ifcopenshell.guid.new() - template.Name = blender_property_set_template.name - template.Description = blender_property_set_template.description - template.TemplateType = blender_property_set_template.template_type - template.ApplicableEntity = blender_property_set_template.applicable_entity - - saved_global_ids = [] - - for blender_property_template in context.scene.BIMProperties.property_templates: - if blender_property_template.global_id: - property_template = ifc.IfcStore.pset_template_file.by_guid(blender_property_template.global_id) - else: - property_template = ifc.IfcStore.pset_template_file.createIfcSimplePropertyTemplate() - property_template.GlobalId = ifcopenshell.guid.new() - if template.HasPropertyTemplates: - has_property_templates = list(template.HasPropertyTemplates) - else: - has_property_templates = [] - has_property_templates.append(property_template) - template.HasPropertyTemplates = has_property_templates - property_template.Name = blender_property_template.name - property_template.Description = blender_property_template.description - property_template.PrimaryMeasureType = blender_property_template.primary_measure_type - property_template.TemplateType = "P_SINGLEVALUE" - property_template.AccessState = "READWRITE" - saved_global_ids.append(property_template.GlobalId) - - for element in template.HasPropertyTemplates: - if element.GlobalId not in saved_global_ids: - ifc.IfcStore.pset_template_file.remove(element) - - ifc.IfcStore.pset_template_file.write(ifc.IfcStore.pset_template_path) - from . import prop - - prop.refreshPropertySetTemplates(self, context) - return {"FINISHED"} - - -class AddPropertyTemplate(bpy.types.Operator): - bl_idname = "bim.add_property_template" - bl_label = "Add Property Template" - - def execute(self, context): - context.scene.BIMProperties.property_templates.add() - return {"FINISHED"} - - -class RemovePropertyTemplate(bpy.types.Operator): - bl_idname = "bim.remove_property_template" - bl_label = "Remove Property Template" - index: bpy.props.IntProperty() - - def execute(self, context): - bpy.context.scene.BIMProperties.property_templates.remove(self.index) - return {"FINISHED"} - - class AddSectionPlane(bpy.types.Operator): bl_idname = "bim.add_section_plane" bl_label = "Add Temporary Section Cutaway" diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index 6b3bc272e3..b2f51af130 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -31,9 +31,6 @@ availablematerialpsets_enum = [] ifcpatchrecipes_enum = [] titleblocks_enum = [] materialpsetnames_enum = [] -psetfiles_enum = [] -psettemplatefiles_enum = [] -propertysettemplates_enum = [] attributes_enum = [] materialattributes_enum = [] contexts_enum = [] @@ -261,32 +258,6 @@ def toggleDecorationsOnLoad(*args): decoration.DecorationsHandler.uninstall() -def getPsetTemplateFiles(self, context): - global psettemplatefiles_enum - if len(psettemplatefiles_enum) < 1: - files = os.listdir(os.path.join(self.data_dir, "pset")) - psettemplatefiles_enum.extend([(f.replace(".ifc", ""), f.replace(".ifc", ""), "") for f in files]) - return psettemplatefiles_enum - - -def refreshPropertySetTemplates(self, context): - global propertysettemplates_enum - propertysettemplates_enum.clear() - getPropertySetTemplates(self, context) - - -def getPropertySetTemplates(self, context): - global propertysettemplates_enum - if len(propertysettemplates_enum) < 1: - ifc.IfcStore.pset_template_path = os.path.join( - context.scene.BIMProperties.data_dir, "pset", context.scene.BIMProperties.pset_template_files + ".ifc" - ) - ifc.IfcStore.pset_template_file = ifcopenshell.open(ifc.IfcStore.pset_template_path) - templates = ifc.IfcStore.pset_template_file.by_type("IfcPropertySetTemplate") - propertysettemplates_enum.extend([(t.GlobalId, t.Name, "") for t in templates]) - return propertysettemplates_enum - - def getMaterialPsetNames(self, context): global materialpsetnames_enum materialpsetnames_enum.clear() @@ -508,180 +479,6 @@ class SmartClashGroup(PropertyGroup): global_ids: CollectionProperty(name="GlobalIDs", type=StrProperty) -class PropertySetTemplate(PropertyGroup): - global_id: StringProperty(name="Global ID") - name: StringProperty(name="Name") - description: StringProperty(name="Description") - template_type: EnumProperty( - 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.", - ), - ], - name="Template Type", - ) - applicable_entity: StringProperty(name="Applicable Entity") - - -class PropertyTemplate(PropertyGroup): - global_id: StringProperty(name="Global ID") - name: StringProperty(name="Name") - description: StringProperty(name="Description") - primary_measure_type: EnumProperty( - items=[ - (x, x, "") - for x in [ - "IfcInteger", - "IfcReal", - "IfcBoolean", - "IfcIdentifier", - "IfcText", - "IfcLabel", - "IfcLogical", - "IfcDateTime", - "IfcDate", - "IfcTime", - "IfcDuration", - "IfcTimeStamp", - "IfcPositiveInteger", - "IfcBinary", - "IfcVolumeMeasure", - "IfcTimeMeasure", - "IfcThermodynamicTemperatureMeasure", - "IfcSolidAngleMeasure", - "IfcPositiveRatioMeasure", - "IfcRatioMeasure", - "IfcPositivePlaneAngleMeasure", - "IfcPlaneAngleMeasure", - "IfcParameterValue", - "IfcNumericMeasure", - "IfcMassMeasure", - "IfcPositiveLengthMeasure", - "IfcLengthMeasure", - "IfcElectricCurrentMeasure", - "IfcDescriptiveMeasure", - "IfcCountMeasure", - "IfcContextDependentMeasure", - "IfcAreaMeasure", - "IfcAmountOfSubstanceMeasure", - "IfcLuminousIntensityMeasure", - "IfcNormalisedRatioMeasure", - "IfcComplexNumber", - "IfcNonNegativeLengthMeasure", - "IfcAbsorbedDoseMeasure", - "IfcAccelerationMeasure", - "IfcAngularVelocityMeasure", - "IfcAreaDensityMeasure", - "IfcCompoundPlaneAngleMeasure", - "IfcCurvatureMeasure", - "IfcDoseEquivalentMeasure", - "IfcDynamicViscosityMeasure", - "IfcElectricCapacitanceMeasure", - "IfcElectricChargeMeasure", - "IfcElectricConductanceMeasure", - "IfcElectricResistanceMeasure", - "IfcElectricVoltageMeasure", - "IfcEnergyMeasure", - "IfcForceMeasure", - "IfcFrequencyMeasure", - "IfcHeatFluxDensityMeasure", - "IfcHeatingValueMeasure", - "IfcIlluminanceMeasure", - "IfcInductanceMeasure", - "IfcIntegerCountRateMeasure", - "IfcIonConcentrationMeasure", - "IfcIsothermalMoistureCapacityMeasure", - "IfcKinematicViscosityMeasure", - "IfcLinearForceMeasure", - "IfcLinearMomentMeasure", - "IfcLinearStiffnessMeasure", - "IfcLinearVelocityMeasure", - "IfcLuminousFluxMeasure", - "IfcLuminousIntensityDistributionMeasure", - "IfcMagneticFluxDensityMeasure", - "IfcMagneticFluxMeasure", - "IfcMassDensityMeasure", - "IfcMassFlowRateMeasure", - "IfcMassPerLengthMeasure", - "IfcModulusOfElasticityMeasure", - "IfcModulusOfLinearSubgradeReactionMeasure", - "IfcModulusOfRotationalSubgradeReactionMeasure", - "IfcModulusOfSubgradeReactionMeasure", - "IfcMoistureDiffusivityMeasure", - "IfcMolecularWeightMeasure", - "IfcMomentOfInertiaMeasure", - "IfcMonetaryMeasure", - "IfcPHMeasure", - "IfcPlanarForceMeasure", - "IfcPowerMeasure", - "IfcPressureMeasure", - "IfcRadioActivityMeasure", - "IfcRotationalFrequencyMeasure", - "IfcRotationalMassMeasure", - "IfcRotationalStiffnessMeasure", - "IfcSectionModulusMeasure", - "IfcSectionalAreaIntegralMeasure", - "IfcShearModulusMeasure", - "IfcSoundPowerLevelMeasure", - "IfcSoundPowerMeasure", - "IfcSoundPressureLevelMeasure", - "IfcSoundPressureMeasure", - "IfcSpecificHeatCapacityMeasure", - "IfcTemperatureGradientMeasure", - "IfcTemperatureRateOfChangeMeasure", - "IfcThermalAdmittanceMeasure", - "IfcThermalConductivityMeasure", - "IfcThermalExpansionCoefficientMeasure", - "IfcThermalResistanceMeasure", - "IfcThermalTransmittanceMeasure", - "IfcTorqueMeasure", - "IfcVaporPermeabilityMeasure", - "IfcVolumetricFlowRateMeasure", - "IfcWarpingConstantMeasure", - "IfcWarpingMomentMeasure", - ] - ], - name="Primary Measure Type", - ) - - class BIMProperties(PropertyGroup): schema_dir: StringProperty(default=os.path.join(cwd, "schema") + os.path.sep, name="Schema Directory") data_dir: StringProperty(default=os.path.join(cwd, "data") + os.path.sep, name="Data Directory") @@ -692,12 +489,6 @@ class BIMProperties(PropertyGroup): available_contexts: EnumProperty(items=[("Model", "Model", ""), ("Plan", "Plan", "")], name="Available Contexts") available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts") available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views") - pset_template_files: EnumProperty( - items=getPsetTemplateFiles, name="Pset Template Files", update=refreshPropertySetTemplates - ) - property_set_templates: EnumProperty(items=getPropertySetTemplates, name="Pset Template Files") - active_property_set_template: PointerProperty(type=PropertySetTemplate) - property_templates: CollectionProperty(name="Property Templates", type=PropertyTemplate) should_section_selected_objects: BoolProperty(name="Section Selected Objects", default=False) section_plane_colour: FloatVectorProperty( name="Temporary Section Cutaway Colour", subtype="COLOR", default=(1, 0, 0), min=0.0, max=1.0 diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index a8af5eeb64..dc231e365b 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -37,50 +37,6 @@ class BIM_PT_object_structural(Panel): row.prop(props, "structural_member_connection") -class BIM_PT_psets(Panel): - bl_label = "IFC Property Sets" - bl_idname = "BIM_PT_psets" - bl_options = {"DEFAULT_CLOSED"} - bl_space_type = "PROPERTIES" - bl_region_type = "WINDOW" - bl_context = "scene" - - def draw(self, context): - layout = self.layout - props = context.scene.BIMProperties - - row = layout.row(align=True) - row.prop(props, "pset_template_files", text="") - - row = layout.row(align=True) - row.prop(props, "property_set_templates", text="") - row.operator("bim.add_property_set_template", text="", icon="ADD") - row.operator("bim.remove_property_set_template", text="", icon="PANEL_CLOSE") - row.operator("bim.edit_property_set_template", text="", icon="IMPORT") - row.operator("bim.save_property_set_template", text="", icon="EXPORT") - - row = layout.row(align=True) - row.prop(props.active_property_set_template, "name") - row = layout.row(align=True) - row.prop(props.active_property_set_template, "description") - row = layout.row(align=True) - row.prop(props.active_property_set_template, "template_type") - row = layout.row(align=True) - row.prop(props.active_property_set_template, "applicable_entity") - - layout.label(text="Property Templates:") - - row = layout.row(align=True) - row.operator("bim.add_property_template") - - for index, template in enumerate(props.property_templates): - row = layout.row(align=True) - row.prop(template, "name", text="") - row.prop(template, "description", text="") - row.prop(template, "primary_measure_type", text="") - row.operator("bim.remove_property_template", icon="X", text="").index = index - - class BIM_PT_presentation_layer_data(Panel): bl_label = "IFC Presentation Layers" bl_idname = "BIM_PT_presentation"