type dropdown now references ifc data types

This commit is contained in:
Vukas Pajic
2021-12-06 12:58:08 +01:00
parent 9d2e27ef48
commit 67d62e5f21
5 changed files with 133 additions and 125 deletions
@@ -394,7 +394,7 @@ class BIM_OT_remove_property_to_edit(bpy.types.Operator):
option: bpy.props.StringProperty()
def execute(self, context):
getattr(context.scene, self.option).remove()
getattr(context.scene, self.option).remove(self.index)
return {"FINISHED"}
@@ -469,6 +469,9 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator):
for prop in props:
value = getattr(prop, prop.get_value_name())
primary_measure_type = prop.primary_measure_type
value_ifc_entity = getattr(self.file, f"create{primary_measure_type}")(value)
new_pset = ifcopenshell.api.run(
"pset.add_pset",
self.file,
@@ -479,7 +482,7 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator):
"pset.edit_pset",
self.file,
pset=new_pset,
properties={prop.property_name:value}
properties={prop.property_name:value_ifc_entity}
)
self.report({'INFO'}, 'Finished applying changes')
@@ -18,7 +18,8 @@
import bpy
import blenderbim.bim.schema
from blenderbim.bim.prop import Attribute
from blenderbim.bim.prop import Attribute, PRIMARY_MEASURE_TYPE
import ifcopenshell
from ifcopenshell.api.pset.data import Data
from blenderbim.bim.ifc import IfcStore
from bpy.types import PropertyGroup
@@ -188,23 +189,25 @@ class AddEditProperties(PropertyGroup):
bool_value: BoolProperty(name="Value")
int_value: IntProperty(name="Value")
float_value: FloatProperty(name="Value")
data_type: EnumProperty(
primary_measure_type: EnumProperty(
items=[
("string", "String", "" ),
("boolean", "True/False", "" ),
("integer", "Integer", "" ),
("float", "Number", "" )],
default="string"
(x, x, "")
for x in PRIMARY_MEASURE_TYPE
],
default="IfcLabel",
name="Primary Measure Type"
)
def get_value_name(self):
if self.data_type == "string":
ifc_data_type = IfcStore.get_schema().declaration_by_name(self.primary_measure_type)
data_type = ifcopenshell.util.attribute.get_primitive_type(ifc_data_type)
if data_type == "string":
return "string_value"
elif self.data_type == "boolean":
elif data_type == "boolean":
return "bool_value"
elif self.data_type == "integer":
elif data_type == "integer":
return "int_value"
elif self.data_type == "float":
elif data_type == "float":
return "float_value"
@@ -441,7 +441,7 @@ class BIM_PT_add_edit_custom_properties(Panel):
row.prop(prop, "pset_name", text="")
row.prop(prop, "property_name", text="")
row.prop(prop, prop.get_value_name(), text="")
row.prop(prop, "data_type", text="")
row.prop(prop, "primary_measure_type", text="")
op = row.operator("bim.remove_property_to_edit",icon="PANEL_CLOSE", text="")
op.index = index
op.option = "AddEditProperties"
@@ -19,7 +19,7 @@
import os
import bpy
import ifcopenshell
from blenderbim.bim.prop import StrProperty, Attribute
from blenderbim.bim.prop import StrProperty, Attribute, PRIMARY_MEASURE_TYPE
from blenderbim.bim.ifc import IfcStore
from bpy.types import PropertyGroup
from bpy.props import (
@@ -146,116 +146,7 @@ class PropTemplate(PropertyGroup):
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",
]
for x in PRIMARY_MEASURE_TYPE
],
name="Primary Measure Type",
)
+111
View File
@@ -40,6 +40,117 @@ cwd = os.path.dirname(os.path.realpath(__file__))
materialpsetnames_enum = []
PRIMARY_MEASURE_TYPE = [
"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",
]
def update_preset(self, context):
from blenderbim.bim.data.ui.presets import presets