mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
New feature to read pset template files
This commit is contained in:
@@ -99,10 +99,17 @@ if bpy is not None:
|
|||||||
operator.OpenUpstream,
|
operator.OpenUpstream,
|
||||||
operator.BIM_OT_CopyAttributesToSelection,
|
operator.BIM_OT_CopyAttributesToSelection,
|
||||||
operator.BIM_OT_ChangeClassificationLevel,
|
operator.BIM_OT_ChangeClassificationLevel,
|
||||||
|
operator.AddPropertySetTemplate,
|
||||||
|
operator.DeletePropertySetTemplate,
|
||||||
|
operator.EditPropertySetTemplate,
|
||||||
|
operator.SavePropertySetTemplate,
|
||||||
|
operator.AddPropertyTemplate,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.Classification,
|
prop.Classification,
|
||||||
prop.ClassificationReference,
|
prop.ClassificationReference,
|
||||||
prop.ClassificationView,
|
prop.ClassificationView,
|
||||||
|
prop.PropertySetTemplate,
|
||||||
|
prop.PropertyTemplate,
|
||||||
prop.BcfTopic,
|
prop.BcfTopic,
|
||||||
prop.BcfTopicLabel,
|
prop.BcfTopicLabel,
|
||||||
prop.BcfTopicFile,
|
prop.BcfTopicFile,
|
||||||
@@ -128,6 +135,7 @@ if bpy is not None:
|
|||||||
prop.BIMCameraProperties,
|
prop.BIMCameraProperties,
|
||||||
ui.BIM_PT_documentation,
|
ui.BIM_PT_documentation,
|
||||||
ui.BIM_PT_bim,
|
ui.BIM_PT_bim,
|
||||||
|
ui.BIM_PT_psets,
|
||||||
ui.BIM_PT_classifications,
|
ui.BIM_PT_classifications,
|
||||||
ui.BIM_PT_search,
|
ui.BIM_PT_search,
|
||||||
ui.BIM_PT_bcf,
|
ui.BIM_PT_bcf,
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
Reference,myref
|
|
||||||
Status,TEMPORARY
|
|
||||||
FireRating,2HR
|
|
||||||
AcousticRating,0.5R
|
|
||||||
IsExternal,True
|
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
Reference,Some reference
|
|
||||||
Status,EXISTING
|
|
||||||
Style,Some style
|
|
||||||
NominalHeight,1.2
|
|
||||||
NominalLength,1.3
|
|
||||||
NominalDepth,1.5
|
|
||||||
MainColor,Blue
|
|
||||||
IsBuiltIn,Uh-huh
|
|
||||||
|
-1
@@ -1 +0,0 @@
|
|||||||
MainColor,Red
|
|
||||||
|
@@ -1735,3 +1735,60 @@ class BIM_OT_ChangeClassificationLevel(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
lst.root = ''
|
lst.root = ''
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class AddPropertySetTemplate(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.add_property_set_template'
|
||||||
|
bl_label = 'Add Property Set Template'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class DeletePropertySetTemplate(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.delete_property_set_template'
|
||||||
|
bl_label = 'Delete Property Set Template'
|
||||||
|
|
||||||
|
def execute(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):
|
||||||
|
f = ifcopenshell.open(os.path.join(context.scene.BIMProperties.data_dir,
|
||||||
|
'pset', context.scene.BIMProperties.pset_template_files + '.ifc'))
|
||||||
|
template = f.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)
|
||||||
|
|
||||||
|
for property_template in template.HasPropertyTemplates:
|
||||||
|
if not property_template.is_a('IfcSimplePropertyTemplate'):
|
||||||
|
continue
|
||||||
|
new = context.scene.BIMProperties.property_templates.add()
|
||||||
|
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):
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class AddPropertyTemplate(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.add_property_template'
|
||||||
|
bl_label = 'Add Property Template'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
return {'FINISHED'}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ featuresfiles_enum = []
|
|||||||
scenarios_enum = []
|
scenarios_enum = []
|
||||||
psetnames_enum = []
|
psetnames_enum = []
|
||||||
psetfiles_enum = []
|
psetfiles_enum = []
|
||||||
|
psettemplatefiles_enum = []
|
||||||
|
propertysettemplates_enum = []
|
||||||
classification_enum = []
|
classification_enum = []
|
||||||
attributes_enum = []
|
attributes_enum = []
|
||||||
overridepsetnames_enum = []
|
overridepsetnames_enum = []
|
||||||
@@ -223,14 +225,32 @@ def refreshPsetFiles(self, context):
|
|||||||
|
|
||||||
def getPsetFiles(self, context):
|
def getPsetFiles(self, context):
|
||||||
global psetfiles_enum
|
global psetfiles_enum
|
||||||
if len(psetfiles_enum) < 1:
|
|
||||||
if not self.pset_name.strip():
|
|
||||||
return psetfiles_enum
|
|
||||||
files = os.listdir(os.path.join(self.data_dir, 'pset', self.pset_name.strip()))
|
|
||||||
psetfiles_enum.extend([(f.replace('.csv', ''), f.replace('.csv', ''), '') for f in files])
|
|
||||||
return psetfiles_enum
|
return psetfiles_enum
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
f = ifcopenshell.open(os.path.join(self.data_dir, 'pset', self.pset_template_files + '.ifc'))
|
||||||
|
templates = f.by_type('IfcPropertySetTemplate')
|
||||||
|
propertysettemplates_enum.extend([(t.GlobalId, t.Name, '') for t in templates])
|
||||||
|
return propertysettemplates_enum
|
||||||
|
|
||||||
|
|
||||||
def getClassifications(self, context):
|
def getClassifications(self, context):
|
||||||
global classification_enum
|
global classification_enum
|
||||||
if len(classification_enum) < 1:
|
if len(classification_enum) < 1:
|
||||||
@@ -574,6 +594,136 @@ def getBcfViewpoints(self, context):
|
|||||||
return bcfviewpoints_enum
|
return bcfviewpoints_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.'),
|
||||||
|
], name="Template Type")
|
||||||
|
applicable_entity: StringProperty(name="Applicable Entity")
|
||||||
|
|
||||||
|
|
||||||
|
class PropertyTemplate(PropertyGroup):
|
||||||
|
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 Classification(PropertyGroup):
|
class Classification(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
source: StringProperty(name="Source")
|
source: StringProperty(name="Source")
|
||||||
@@ -707,6 +857,10 @@ class BIMProperties(PropertyGroup):
|
|||||||
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
||||||
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
||||||
classification_references: PointerProperty(type=ClassificationView)
|
classification_references: PointerProperty(type=ClassificationView)
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
class BCFProperties(PropertyGroup):
|
class BCFProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -162,6 +162,50 @@ class BIM_PT_classification_references(Panel):
|
|||||||
row.prop(props, 'classifications')
|
row.prop(props, 'classifications')
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_psets(Panel):
|
||||||
|
bl_label = 'Psets'
|
||||||
|
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.delete_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_classification', icon='X', text='').classification_index = index
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_classifications(Panel):
|
class BIM_PT_classifications(Panel):
|
||||||
bl_label = 'Classifications'
|
bl_label = 'Classifications'
|
||||||
bl_idname = 'BIM_PT_classifications'
|
bl_idname = 'BIM_PT_classifications'
|
||||||
|
|||||||
Reference in New Issue
Block a user