mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
BBIM: Replace "GuessAllQuantities" with "CalculateQuantities in QTO subpanel, and also re-calculate for all selected objects
This commit is contained in:
@@ -28,7 +28,7 @@ classes = (
|
|||||||
operator.EnablePsetEditing,
|
operator.EnablePsetEditing,
|
||||||
operator.GuessQuantity,
|
operator.GuessQuantity,
|
||||||
operator.CalculateQuantity,
|
operator.CalculateQuantity,
|
||||||
operator.GuessAllQuantities,
|
operator.CalculateAllQuantities,
|
||||||
operator.RemovePset,
|
operator.RemovePset,
|
||||||
operator.TogglePsetExpansion,
|
operator.TogglePsetExpansion,
|
||||||
operator.BIM_OT_add_property_to_edit,
|
operator.BIM_OT_add_property_to_edit,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import blenderbim.bim.helper
|
|||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
import blenderbim.core.pset as core
|
import blenderbim.core.pset as core
|
||||||
|
import blenderbim.core.qto as QtoCore
|
||||||
import blenderbim.bim.module.pset.data
|
import blenderbim.bim.module.pset.data
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from ifcopenshell.api.pset.data import Data
|
from ifcopenshell.api.pset.data import Data
|
||||||
@@ -333,6 +334,7 @@ class AddQto(bpy.types.Operator, Operator):
|
|||||||
bl_idname = "bim.add_qto"
|
bl_idname = "bim.add_qto"
|
||||||
bl_label = "Add Qto"
|
bl_label = "Add Qto"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
bl_description = "Add Quantity Take Off"
|
||||||
obj: bpy.props.StringProperty()
|
obj: bpy.props.StringProperty()
|
||||||
obj_type: bpy.props.StringProperty()
|
obj_type: bpy.props.StringProperty()
|
||||||
|
|
||||||
@@ -434,31 +436,18 @@ class GuessQuantity(bpy.types.Operator):
|
|||||||
return unit_settings.length_unit[0 : -len("METERS")], "METRE"
|
return unit_settings.length_unit[0 : -len("METERS")], "METRE"
|
||||||
|
|
||||||
|
|
||||||
class GuessAllQuantities(bpy.types.Operator):
|
class CalculateAllQuantities(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.guess_all_quantities"
|
bl_idname = "bim.calculate_all_quantities"
|
||||||
bl_label = "Guess All Quantities"
|
bl_label = "Calculate All Quantities"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
pset_id: bpy.props.IntProperty()
|
bl_description = "Calculate all quantities for all selected objects"
|
||||||
obj_name: bpy.props.StringProperty()
|
|
||||||
obj_type: bpy.props.StringProperty()
|
|
||||||
|
|
||||||
def execute(self, context):
|
@classmethod
|
||||||
self.qto_calculator = QtoCalculator()
|
def poll(cls, context):
|
||||||
obj = context.active_object
|
return context.active_object
|
||||||
bpy.ops.bim.enable_pset_editing(pset_id=self.pset_id, obj=self.obj_name, obj_type=self.obj_type)
|
|
||||||
for prop in obj.PsetProperties.properties:
|
def _execute(self, context):
|
||||||
if (
|
QtoCore.calculate_all_qtos(tool.Ifc, tool.Qto, selected_objects = context.selected_objects)
|
||||||
"length" in prop.name.lower()
|
|
||||||
or "area" in prop.name.lower()
|
|
||||||
or "volume" 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()
|
|
||||||
):
|
|
||||||
bpy.ops.bim.guess_quantity(prop=prop.name)
|
|
||||||
bpy.ops.bim.edit_pset(obj=self.obj_name, obj_type=self.obj_type)
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class CopyPropertyToSelection(bpy.types.Operator, Operator):
|
class CopyPropertyToSelection(bpy.types.Operator, Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user