New feature to read pset template files

This commit is contained in:
Dion Moult
2020-04-24 17:14:07 +10:00
parent a90ad6e16c
commit 9ad57d658e
8 changed files with 268 additions and 19 deletions
@@ -99,10 +99,17 @@ if bpy is not None:
operator.OpenUpstream,
operator.BIM_OT_CopyAttributesToSelection,
operator.BIM_OT_ChangeClassificationLevel,
operator.AddPropertySetTemplate,
operator.DeletePropertySetTemplate,
operator.EditPropertySetTemplate,
operator.SavePropertySetTemplate,
operator.AddPropertyTemplate,
prop.StrProperty,
prop.Classification,
prop.ClassificationReference,
prop.ClassificationView,
prop.PropertySetTemplate,
prop.PropertyTemplate,
prop.BcfTopic,
prop.BcfTopicLabel,
prop.BcfTopicFile,
@@ -128,6 +135,7 @@ if bpy is not None:
prop.BIMCameraProperties,
ui.BIM_PT_documentation,
ui.BIM_PT_bim,
ui.BIM_PT_psets,
ui.BIM_PT_classifications,
ui.BIM_PT_search,
ui.BIM_PT_bcf,
@@ -1,5 +0,0 @@
Reference,myref
Status,TEMPORARY
FireRating,2HR
AcousticRating,0.5R
IsExternal,True
1 Reference myref
2 Status TEMPORARY
3 FireRating 2HR
4 AcousticRating 0.5R
5 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 Reference Some reference
2 Status EXISTING
3 Style Some style
4 NominalHeight 1.2
5 NominalLength 1.3
6 NominalDepth 1.5
7 MainColor Blue
8 IsBuiltIn Uh-huh
@@ -1 +0,0 @@
MainColor,Red
1 MainColor Red
@@ -1735,3 +1735,60 @@ class BIM_OT_ChangeClassificationLevel(bpy.types.Operator):
else:
lst.root = ''
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'}
+159 -5
View File
@@ -31,6 +31,8 @@ featuresfiles_enum = []
scenarios_enum = []
psetnames_enum = []
psetfiles_enum = []
psettemplatefiles_enum = []
propertysettemplates_enum = []
classification_enum = []
attributes_enum = []
overridepsetnames_enum = []
@@ -223,14 +225,32 @@ def refreshPsetFiles(self, context):
def getPsetFiles(self, context):
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
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):
global classification_enum
if len(classification_enum) < 1:
@@ -574,6 +594,136 @@ def getBcfViewpoints(self, context):
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):
name: StringProperty(name="Name")
source: StringProperty(name="Source")
@@ -707,6 +857,10 @@ class BIMProperties(PropertyGroup):
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
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):
+44
View File
@@ -162,6 +162,50 @@ class BIM_PT_classification_references(Panel):
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):
bl_label = 'Classifications'
bl_idname = 'BIM_PT_classifications'