mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Purge guess quantity feature. It will be reintroduced as a separate tool.
This commit is contained in:
@@ -27,7 +27,6 @@ classes = (
|
||||
operator.DisablePsetEditing,
|
||||
operator.EditPset,
|
||||
operator.EnablePsetEditing,
|
||||
operator.GuessQuantity,
|
||||
operator.CalculateQuantity,
|
||||
operator.RemovePset,
|
||||
operator.TogglePsetExpansion,
|
||||
|
||||
@@ -241,28 +241,6 @@ class CalculateQuantity(bpy.types.Operator):
|
||||
return round(quantity, 3)
|
||||
|
||||
|
||||
class GuessQuantity(bpy.types.Operator):
|
||||
bl_idname = "bim.guess_quantity"
|
||||
bl_label = "Guess Quantity"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = (
|
||||
"Calculate the quantity by guessing the formula from the quantity name. "
|
||||
"Less reliable than Calculate Quantity"
|
||||
)
|
||||
prop: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.qto_calculator = QtoCalculator()
|
||||
obj = context.active_object
|
||||
prop = obj.PsetProperties.properties.get(self.prop)
|
||||
prop.metadata.float_value = self.guess_quantity(obj, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
def guess_quantity(self, obj, context):
|
||||
quantity = self.qto_calculator.guess_quantity(self.prop, [p.name for p in obj.PsetProperties.properties], obj)
|
||||
return round(quantity, 3) if quantity is not None else None
|
||||
|
||||
|
||||
class CopyPropertyToSelection(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.copy_property_to_selection"
|
||||
bl_label = "Copy Property To Selection"
|
||||
|
||||
@@ -66,52 +66,6 @@ class QtoCalculator:
|
||||
|
||||
return tool.Qto.convert_to_project_units(value, qto_name, quantity_name) or value
|
||||
|
||||
def guess_quantity(
|
||||
self, prop_name: str, alternative_prop_names: list[str], obj: bpy.types.Object
|
||||
) -> Union[float, None]:
|
||||
"""guess the value of the quantity by name, returns the value in the project units"""
|
||||
prop_name = prop_name.lower()
|
||||
alternative_prop_names = [p.lower() for p in alternative_prop_names]
|
||||
value = None
|
||||
if "length" in prop_name and "width" not in alternative_prop_names and "height" not in alternative_prop_names:
|
||||
value = self.get_linear_length(obj)
|
||||
elif "length" in prop_name:
|
||||
value = self.get_length(obj)
|
||||
elif "width" in prop_name and "length" not in alternative_prop_names:
|
||||
value = self.get_length(obj)
|
||||
elif "width" in prop_name:
|
||||
value = self.get_width(obj)
|
||||
elif "height" in prop_name or "depth" in prop_name:
|
||||
value = self.get_height(obj)
|
||||
elif "perimeter" in prop_name:
|
||||
value = self.get_net_perimeter(obj)
|
||||
elif "area" in prop_name and ("footprint" in prop_name or "section" in prop_name or "floor" in prop_name):
|
||||
value = self.get_net_footprint_area(obj)
|
||||
elif "area" in prop_name and "side" in prop_name:
|
||||
value = self.get_side_area(obj)
|
||||
elif "area" in prop_name:
|
||||
value = self.get_gross_surface_area(obj)
|
||||
elif "volume" in prop_name and "gross" in prop_name:
|
||||
value = self.get_gross_volume(obj)
|
||||
elif "volume" in prop_name:
|
||||
value = self.get_net_volume(obj)
|
||||
|
||||
if value is None:
|
||||
return
|
||||
|
||||
unit_type_keywords: dict[str, QuanityTypes] = {
|
||||
"length": "Q_LENGTH",
|
||||
"width": "Q_LENGTH",
|
||||
"height": "Q_LENGTH",
|
||||
"depth": "Q_LENGTH",
|
||||
"perimeter": "Q_LENGTH",
|
||||
"area": "Q_AREA",
|
||||
"volume": "Q_VOLUME",
|
||||
}
|
||||
|
||||
unit_type = next(unit_type_keywords[k] for k in unit_type_keywords if k in prop_name)
|
||||
return tool.Qto.convert_to_project_units(value, quantity_type=unit_type) or value
|
||||
|
||||
def get_units(self, o: bpy.types.Object, vg_index: int) -> int:
|
||||
return len([v for v in o.data.vertices if vg_index in [g.group for g in v.groups]])
|
||||
|
||||
|
||||
@@ -163,22 +163,6 @@ def draw_psetqto_editable_ui(box, props, prop):
|
||||
if prop.metadata.has_calculator:
|
||||
op = row.operator("bim.calculate_quantity", icon="MOD_EDGESPLIT", text="")
|
||||
op.prop = prop.name
|
||||
# Old "guess quantity" feature to be removed once new calculator is comprehensive
|
||||
if (
|
||||
"length" in prop.name.lower()
|
||||
or "width" in prop.name.lower()
|
||||
or "height" in prop.name.lower()
|
||||
or "depth" in prop.name.lower()
|
||||
or "perimeter" in prop.name.lower()
|
||||
):
|
||||
op = row.operator("bim.guess_quantity", icon="IPO_EASE_IN_OUT", text="")
|
||||
op.prop = prop.name
|
||||
elif "area" in prop.name.lower():
|
||||
op = row.operator("bim.guess_quantity", icon="MESH_CIRCLE", text="")
|
||||
op.prop = prop.name
|
||||
elif "volume" in prop.name.lower():
|
||||
op = row.operator("bim.guess_quantity", icon="SPHERE", text="")
|
||||
op.prop = prop.name
|
||||
|
||||
|
||||
class BIM_PT_object_psets(Panel):
|
||||
|
||||
@@ -636,17 +636,16 @@ class Pset:
|
||||
|
||||
@interface
|
||||
class Qto:
|
||||
def get_radius_of_selected_vertices(cls, obj): pass
|
||||
def set_qto_result(cls, result): pass
|
||||
def get_applicable_quantity_names(cls, qto_name): pass
|
||||
def get_applicable_base_quantity_name(cls, product): pass
|
||||
def get_rounded_value(cls, new_quantity): pass
|
||||
def get_calculated_object_quantities(cls, calculator, baste_qto, object): pass
|
||||
def add_object_base_qto(cls, object): pass
|
||||
def add_product_base_qto(cls, product): pass
|
||||
def get_applicable_base_quantity_name(cls, product): pass
|
||||
def get_applicable_quantity_names(cls, qto_name): pass
|
||||
def get_calculated_object_quantities(cls, calculator, baste_qto, object): pass
|
||||
def get_new_calculated_quantity(cls, qto_name, quantity_name, object): pass
|
||||
def get_new_guessed_quantity(cls, object, qto_name, quantity_name, ): pass
|
||||
def get_radius_of_selected_vertices(cls, obj): pass
|
||||
def get_related_cost_item_quantities(cls, product): pass
|
||||
def get_rounded_value(cls, new_quantity): pass
|
||||
def set_qto_result(cls, result): pass
|
||||
|
||||
|
||||
@interface
|
||||
|
||||
@@ -95,12 +95,6 @@ class Qto(blenderbim.core.tool.Qto):
|
||||
def get_new_calculated_quantity(cls, qto_name: str, quantity_name: str, obj: bpy.types.Object) -> float:
|
||||
return QtoCalculator().calculate_quantity(qto_name, quantity_name, obj)
|
||||
|
||||
@classmethod
|
||||
def get_new_guessed_quantity(
|
||||
cls, obj: bpy.types.Object, quantity_name: str, alternative_prop_names: list[str]
|
||||
) -> Union[float, None]:
|
||||
return QtoCalculator().guess_quantity(quantity_name, alternative_prop_names, obj)
|
||||
|
||||
@classmethod
|
||||
def get_rounded_value(cls, new_quantity: float) -> float:
|
||||
return round(new_quantity, 3)
|
||||
@@ -158,26 +152,6 @@ class Qto(blenderbim.core.tool.Qto):
|
||||
)
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def get_guessed_quantities(
|
||||
cls, obj: bpy.types.Object, pset_qto_properties: list[ifcopenshell.entity_instance]
|
||||
) -> dict[str, float]:
|
||||
calculated_quantities = {}
|
||||
for pset_qto_property in pset_qto_properties:
|
||||
quantity_name = pset_qto_property.get_info()["Name"]
|
||||
alternative_prop_names = [p.get_info()["Name"] for p in pset_qto_properties]
|
||||
|
||||
new_quantity = cls.get_new_guessed_quantity(obj, quantity_name, alternative_prop_names)
|
||||
|
||||
if not new_quantity:
|
||||
new_quantity = 0
|
||||
else:
|
||||
new_quantity = cls.get_rounded_value(new_quantity)
|
||||
|
||||
calculated_quantities[quantity_name] = new_quantity
|
||||
|
||||
return calculated_quantities
|
||||
|
||||
@classmethod
|
||||
def get_base_qto(cls, product: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||
if not hasattr(product, "IsDefinedBy"):
|
||||
|
||||
Reference in New Issue
Block a user