mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 23:50:59 +00:00
Primary measure type lists are now dynamically generated based on the schema.
This commit is contained in:
@@ -119,7 +119,9 @@ class IfcStore:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_schema():
|
def get_schema():
|
||||||
if IfcStore.file is None:
|
if IfcStore.file is None:
|
||||||
return
|
IfcStore.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(
|
||||||
|
bpy.context.scene.BIMProjectProperties.export_schema
|
||||||
|
)
|
||||||
elif IfcStore.schema is None:
|
elif IfcStore.schema is None:
|
||||||
IfcStore.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(IfcStore.file.schema)
|
IfcStore.schema = ifcopenshell.ifcopenshell_wrapper.schema_by_name(IfcStore.file.schema)
|
||||||
return IfcStore.schema
|
return IfcStore.schema
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ classes = (
|
|||||||
ui.BIM_PT_bulk_property_editor,
|
ui.BIM_PT_bulk_property_editor,
|
||||||
ui.BIM_PT_rename_parameters,
|
ui.BIM_PT_rename_parameters,
|
||||||
ui.BIM_PT_add_edit_custom_properties,
|
ui.BIM_PT_add_edit_custom_properties,
|
||||||
ui.BIM_PT_delete_psets
|
ui.BIM_PT_delete_psets,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ def register():
|
|||||||
bpy.types.Scene.AddEditProperties = bpy.props.CollectionProperty(type=prop.AddEditProperties)
|
bpy.types.Scene.AddEditProperties = bpy.props.CollectionProperty(type=prop.AddEditProperties)
|
||||||
bpy.types.Scene.DeletePsets = bpy.props.CollectionProperty(type=prop.DeletePsets)
|
bpy.types.Scene.DeletePsets = bpy.props.CollectionProperty(type=prop.DeletePsets)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
del bpy.types.Object.PsetProperties
|
del bpy.types.Object.PsetProperties
|
||||||
del bpy.types.Material.PsetProperties
|
del bpy.types.Material.PsetProperties
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ def refresh():
|
|||||||
ResourcePsetsData.is_loaded = False
|
ResourcePsetsData.is_loaded = False
|
||||||
ProfilePsetsData.is_loaded = False
|
ProfilePsetsData.is_loaded = False
|
||||||
WorkSchedulePsetsData.is_loaded = False
|
WorkSchedulePsetsData.is_loaded = False
|
||||||
|
AddEditCustomPropertiesData.is_loaded = False
|
||||||
|
|
||||||
|
|
||||||
class Data:
|
class Data:
|
||||||
@@ -156,3 +157,18 @@ class WorkSchedulePsetsData(Data):
|
|||||||
ifc_definition_id = bpy.context.scene.BIMWorkScheduleProperties.active_work_schedule_id
|
ifc_definition_id = bpy.context.scene.BIMWorkScheduleProperties.active_work_schedule_id
|
||||||
cls.data = {"psets": cls.psetqtos(tool.Ifc.get().by_id(ifc_definition_id), psets_only=True)}
|
cls.data = {"psets": cls.psetqtos(tool.Ifc.get().by_id(ifc_definition_id), psets_only=True)}
|
||||||
cls.is_loaded = True
|
cls.is_loaded = True
|
||||||
|
|
||||||
|
|
||||||
|
class AddEditCustomPropertiesData:
|
||||||
|
data = {}
|
||||||
|
is_loaded = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls):
|
||||||
|
cls.data = {"primary_measure_type": cls.primary_measure_type()}
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def primary_measure_type(cls):
|
||||||
|
schema = tool.Ifc.schema()
|
||||||
|
return [(t, t, "") for t in sorted([d.name() for d in schema.declarations() if hasattr(d, "declared_type")])]
|
||||||
|
|||||||
@@ -426,11 +426,11 @@ class BIM_OT_rename_parameters(bpy.types.Operator):
|
|||||||
|
|
||||||
for ifc_element in all_ifc_elements:
|
for ifc_element in all_ifc_elements:
|
||||||
for definition in ifc_element.IsDefinedBy:
|
for definition in ifc_element.IsDefinedBy:
|
||||||
if definition.is_a('IfcRelDefinesByProperties'):
|
if definition.is_a("IfcRelDefinesByProperties"):
|
||||||
prop_set = definition.RelatingPropertyDefinition
|
prop_set = definition.RelatingPropertyDefinition
|
||||||
self.rename_property(prop_set, props_to_map, ifc_element)
|
self.rename_property(prop_set, props_to_map, ifc_element)
|
||||||
|
|
||||||
self.report({'INFO'}, 'Finished applying changes')
|
self.report({"INFO"}, "Finished applying changes")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def rename_property(self, property_set, properties_to_map, ifc_element):
|
def rename_property(self, property_set, properties_to_map, ifc_element):
|
||||||
@@ -473,20 +473,12 @@ class BIM_OT_add_edit_custom_property(bpy.types.Operator):
|
|||||||
primary_measure_type = prop.primary_measure_type
|
primary_measure_type = prop.primary_measure_type
|
||||||
value_ifc_entity = getattr(self.file, f"create{primary_measure_type}")(value)
|
value_ifc_entity = getattr(self.file, f"create{primary_measure_type}")(value)
|
||||||
|
|
||||||
new_pset = ifcopenshell.api.run(
|
new_pset = ifcopenshell.api.run("pset.add_pset", self.file, product=ifc_element, name=prop.pset_name)
|
||||||
"pset.add_pset",
|
|
||||||
self.file,
|
|
||||||
product=ifc_element,
|
|
||||||
name=prop.pset_name
|
|
||||||
)
|
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"pset.edit_pset",
|
"pset.edit_pset", self.file, pset=new_pset, properties={prop.property_name: value_ifc_entity}
|
||||||
self.file,
|
)
|
||||||
pset=new_pset,
|
|
||||||
properties={prop.property_name:value_ifc_entity}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.report({'INFO'}, 'Finished applying changes')
|
self.report({"INFO"}, "Finished applying changes")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -517,16 +509,16 @@ class BIM_OT_bulk_remove_psets(bpy.types.Operator):
|
|||||||
if pset in psets:
|
if pset in psets:
|
||||||
try:
|
try:
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"pset.remove_pset",
|
"pset.remove_pset",
|
||||||
self.file,
|
self.file,
|
||||||
**{
|
**{
|
||||||
"product": self.file.by_id(ifc_definition_id),
|
"product": self.file.by_id(ifc_definition_id),
|
||||||
"pset": self.file.by_id(psets[pset]["id"]),
|
"pset": self.file.by_id(psets[pset]["id"]),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass #Sometimes the pset id is not found, I'm not sure why this happens though. - vulevukusej
|
pass # Sometimes the pset id is not found, I'm not sure why this happens though. - vulevukusej
|
||||||
Data.load(IfcStore.get_file(), ifc_definition_id)
|
Data.load(IfcStore.get_file(), ifc_definition_id)
|
||||||
|
|
||||||
self.report({'INFO'}, 'Finished applying changes')
|
self.report({"INFO"}, "Finished applying changes")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -18,9 +18,10 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import blenderbim.bim.schema
|
import blenderbim.bim.schema
|
||||||
from blenderbim.bim.prop import Attribute, PRIMARY_MEASURE_TYPE
|
from blenderbim.bim.prop import Attribute
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from ifcopenshell.api.pset.data import Data
|
from ifcopenshell.api.pset.data import Data
|
||||||
|
from blenderbim.bim.module.pset.data import AddEditCustomPropertiesData
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
from bpy.props import (
|
from bpy.props import (
|
||||||
@@ -132,6 +133,12 @@ def getQtoNames(self, context):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def get_primary_measure_type(self, context):
|
||||||
|
if not AddEditCustomPropertiesData.is_loaded:
|
||||||
|
AddEditCustomPropertiesData.load()
|
||||||
|
return AddEditCustomPropertiesData.data["primary_measure_type"]
|
||||||
|
|
||||||
|
|
||||||
class PsetProperties(PropertyGroup):
|
class PsetProperties(PropertyGroup):
|
||||||
active_pset_id: IntProperty(name="Active Pset ID")
|
active_pset_id: IntProperty(name="Active Pset ID")
|
||||||
active_pset_name: StringProperty(name="Pset Name")
|
active_pset_name: StringProperty(name="Pset Name")
|
||||||
@@ -189,14 +196,7 @@ class AddEditProperties(PropertyGroup):
|
|||||||
bool_value: BoolProperty(name="Value")
|
bool_value: BoolProperty(name="Value")
|
||||||
int_value: IntProperty(name="Value")
|
int_value: IntProperty(name="Value")
|
||||||
float_value: FloatProperty(name="Value")
|
float_value: FloatProperty(name="Value")
|
||||||
primary_measure_type: EnumProperty(
|
primary_measure_type: EnumProperty(items=get_primary_measure_type, name="Primary Measure Type")
|
||||||
items=[
|
|
||||||
(x, x, "")
|
|
||||||
for x in PRIMARY_MEASURE_TYPE
|
|
||||||
],
|
|
||||||
default="IfcLabel",
|
|
||||||
name="Primary Measure Type"
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_value_name(self):
|
def get_value_name(self):
|
||||||
ifc_data_type = IfcStore.get_schema().declaration_by_name(self.primary_measure_type)
|
ifc_data_type = IfcStore.get_schema().declaration_by_name(self.primary_measure_type)
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
|
# Copyright (C) 2022 Dion Moult <dion@thinkmoult.com>
|
||||||
|
#
|
||||||
|
# This file is part of BlenderBIM Add-on.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
|
|
||||||
|
def refresh():
|
||||||
|
PsetTemplatesData.is_loaded = False
|
||||||
|
|
||||||
|
|
||||||
|
class PsetTemplatesData:
|
||||||
|
data = {}
|
||||||
|
is_loaded = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def load(cls):
|
||||||
|
cls.data = {"primary_measure_type": cls.primary_measure_type()}
|
||||||
|
cls.is_loaded = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def primary_measure_type(cls):
|
||||||
|
schema = tool.Ifc.schema()
|
||||||
|
return [(t, t, "") for t in sorted([d.name() for d in schema.declarations() if hasattr(d, "declared_type")])]
|
||||||
@@ -19,7 +19,8 @@
|
|||||||
import os
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
from blenderbim.bim.prop import StrProperty, Attribute, PRIMARY_MEASURE_TYPE
|
from blenderbim.bim.module.pset_template.data import PsetTemplatesData
|
||||||
|
from blenderbim.bim.prop import StrProperty, Attribute
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
from bpy.props import (
|
from bpy.props import (
|
||||||
@@ -87,6 +88,12 @@ def getPsetTemplates(self, context):
|
|||||||
return psettemplates_enum
|
return psettemplates_enum
|
||||||
|
|
||||||
|
|
||||||
|
def get_primary_measure_type(self, context):
|
||||||
|
if not PsetTemplatesData.is_loaded:
|
||||||
|
PsetTemplatesData.load()
|
||||||
|
return PsetTemplatesData.data["primary_measure_type"]
|
||||||
|
|
||||||
|
|
||||||
class PsetTemplate(PropertyGroup):
|
class PsetTemplate(PropertyGroup):
|
||||||
global_id: StringProperty(name="Global ID")
|
global_id: StringProperty(name="Global ID")
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
@@ -143,13 +150,7 @@ class PropTemplate(PropertyGroup):
|
|||||||
global_id: StringProperty(name="Global ID")
|
global_id: StringProperty(name="Global ID")
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
description: StringProperty(name="Description")
|
description: StringProperty(name="Description")
|
||||||
primary_measure_type: EnumProperty(
|
primary_measure_type: EnumProperty(items=get_primary_measure_type, name="Primary Measure Type")
|
||||||
items=[
|
|
||||||
(x, x, "")
|
|
||||||
for x in PRIMARY_MEASURE_TYPE
|
|
||||||
],
|
|
||||||
name="Primary Measure Type",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BIMPsetTemplateProperties(PropertyGroup):
|
class BIMPsetTemplateProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021, 2022 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
# This file is part of BlenderBIM Add-on.
|
# This file is part of BlenderBIM Add-on.
|
||||||
#
|
#
|
||||||
@@ -42,117 +42,6 @@ cwd = os.path.dirname(os.path.realpath(__file__))
|
|||||||
|
|
||||||
materialpsetnames_enum = []
|
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):
|
def update_preset(self, context):
|
||||||
from blenderbim.bim.data.ui.presets import presets
|
from blenderbim.bim.data.ui.presets import presets
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def edit_structural_analysis_model(ifc, structural):
|
|||||||
**{
|
**{
|
||||||
"structural_analysis_model": structural.get_active_structural_analysis_model(),
|
"structural_analysis_model": structural.get_active_structural_analysis_model(),
|
||||||
"attributes": attributes,
|
"attributes": attributes,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
structural.load_structural_analysis_models()
|
structural.load_structural_analysis_models()
|
||||||
structural.disable_editing_structural_analysis_model()
|
structural.disable_editing_structural_analysis_model()
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ class Ifc(blenderbim.core.tool.Ifc):
|
|||||||
if IfcStore.get_file():
|
if IfcStore.get_file():
|
||||||
return IfcStore.get_file().schema
|
return IfcStore.get_file().schema
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def schema(cls):
|
||||||
|
return IfcStore.get_schema()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_entity(cls, obj):
|
def get_entity(cls, obj):
|
||||||
ifc = IfcStore.get_file()
|
ifc = IfcStore.get_file()
|
||||||
|
|||||||
Reference in New Issue
Block a user