mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 17:36:29 +00:00
Minor fix. See #2533.
This commit is contained in:
@@ -32,6 +32,7 @@ from blenderbim.bim.ifc import IfcStore
|
|||||||
from ifcopenshell.api.pset.data import Data
|
from ifcopenshell.api.pset.data import Data
|
||||||
from ifcopenshell.api.cost.data import Data as CostData
|
from ifcopenshell.api.cost.data import Data as CostData
|
||||||
from blenderbim.bim.module.pset.qto_calculator import QtoCalculator
|
from blenderbim.bim.module.pset.qto_calculator import QtoCalculator
|
||||||
|
from blenderbim.bim.module.pset.calc_quantity_function_mapper import mapper
|
||||||
|
|
||||||
|
|
||||||
class Operator:
|
class Operator:
|
||||||
@@ -100,13 +101,13 @@ class EnablePsetEditing(bpy.types.Operator):
|
|||||||
if not prop_template.is_a("IfcSimplePropertyTemplate"):
|
if not prop_template.is_a("IfcSimplePropertyTemplate"):
|
||||||
continue # Other types not yet supported
|
continue # Other types not yet supported
|
||||||
if prop_template.TemplateType == "P_SINGLEVALUE":
|
if prop_template.TemplateType == "P_SINGLEVALUE":
|
||||||
self.load_single_value(prop_template, data)
|
self.load_single_value(pset_template, prop_template, data)
|
||||||
elif prop_template.TemplateType.startswith("Q_"):
|
elif prop_template.TemplateType.startswith("Q_"):
|
||||||
self.load_single_value(prop_template, data)
|
self.load_single_value(pset_template, prop_template, data)
|
||||||
elif prop_template.TemplateType == "P_ENUMERATEDVALUE":
|
elif prop_template.TemplateType == "P_ENUMERATEDVALUE":
|
||||||
self.load_enumerated_value(prop_template, data)
|
self.load_enumerated_value(prop_template, data)
|
||||||
|
|
||||||
def load_single_value(self, prop_template, data):
|
def load_single_value(self, pset_template, prop_template, data):
|
||||||
prop = self.props.properties.add()
|
prop = self.props.properties.add()
|
||||||
prop.name = prop_template.Name
|
prop.name = prop_template.Name
|
||||||
prop.value_type = "IfcPropertySingleValue"
|
prop.value_type = "IfcPropertySingleValue"
|
||||||
@@ -115,6 +116,7 @@ class EnablePsetEditing(bpy.types.Operator):
|
|||||||
metadata.is_null = data.get(prop_template.Name, None) is None
|
metadata.is_null = data.get(prop_template.Name, None) is None
|
||||||
metadata.is_optional = True
|
metadata.is_optional = True
|
||||||
metadata.is_uri = prop_template.PrimaryMeasureType == "IfcURIReference"
|
metadata.is_uri = prop_template.PrimaryMeasureType == "IfcURIReference"
|
||||||
|
metadata.has_calculator = bool(mapper.get(pset_template.Name, {}).get(prop_template.Name, None))
|
||||||
metadata.data_type = self.get_data_type(prop_template)
|
metadata.data_type = self.get_data_type(prop_template)
|
||||||
|
|
||||||
if metadata.data_type == "string":
|
if metadata.data_type == "string":
|
||||||
@@ -381,7 +383,6 @@ class CalculateQuantity(bpy.types.Operator):
|
|||||||
return unit_settings.length_unit[0 : -len("METERS")], "METRE"
|
return unit_settings.length_unit[0 : -len("METERS")], "METRE"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GuessQuantity(bpy.types.Operator):
|
class GuessQuantity(bpy.types.Operator):
|
||||||
bl_idname = "bim.guess_quantity"
|
bl_idname = "bim.guess_quantity"
|
||||||
bl_label = "Guess Quantity"
|
bl_label = "Guess Quantity"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
from bpy.types import Panel
|
from bpy.types import Panel
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.helper import prop_with_search
|
from blenderbim.bim.helper import prop_with_search
|
||||||
from blenderbim.bim.module.pset.calc_quantity_function_mapper import mapper
|
|
||||||
from blenderbim.bim.module.pset.data import (
|
from blenderbim.bim.module.pset.data import (
|
||||||
ObjectPsetsData,
|
ObjectPsetsData,
|
||||||
ObjectQtosData,
|
ObjectQtosData,
|
||||||
@@ -140,11 +139,10 @@ def draw_psetqto_ui(context, pset_id, pset, props, layout, obj_type):
|
|||||||
def draw_psetqto_editable_ui(box, props, prop):
|
def draw_psetqto_editable_ui(box, props, prop):
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
draw_property(prop, row, copy_operator="bim.copy_property_to_selection")
|
draw_property(prop, row, copy_operator="bim.copy_property_to_selection")
|
||||||
qto_name = ObjectQtosData.data['qtos'][0]['Name']
|
if prop.metadata.has_calculator:
|
||||||
if qto_name in mapper.keys():
|
op = row.operator("bim.calculate_quantity", icon="MOD_EDGESPLIT", text="")
|
||||||
if prop.name in mapper[qto_name]:
|
op.prop = prop.name
|
||||||
op = row.operator("bim.calculate_quantity", icon="MOD_EDGESPLIT", text="")
|
# Old "guess quantity" feature to be removed once new calculator is comprehensive
|
||||||
op.prop = prop.name
|
|
||||||
if (
|
if (
|
||||||
"length" in prop.name.lower()
|
"length" in prop.name.lower()
|
||||||
or "width" in prop.name.lower()
|
or "width" in prop.name.lower()
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ class Attribute(PropertyGroup):
|
|||||||
is_optional: BoolProperty(name="Is Optional")
|
is_optional: BoolProperty(name="Is Optional")
|
||||||
is_uri: BoolProperty(name="Is Uri", default=False)
|
is_uri: BoolProperty(name="Is Uri", default=False)
|
||||||
is_selected: BoolProperty(name="Is Selected", default=False)
|
is_selected: BoolProperty(name="Is Selected", default=False)
|
||||||
|
has_calculator: BoolProperty(name="Has Calculator", default=False)
|
||||||
|
|
||||||
def get_value(self):
|
def get_value(self):
|
||||||
if self.is_null:
|
if self.is_null:
|
||||||
|
|||||||
Reference in New Issue
Block a user