mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
bim.calculate_resource_quantity #5744
Added operator to calculate resource quantity based on the output products and the quantity Name. See video demo - https://imgchest.com/p/9rydjlbmnyk
This commit is contained in:
@@ -25,6 +25,7 @@ classes = (
|
||||
operator.AddProductivityData,
|
||||
operator.AssignResource,
|
||||
operator.CalculateResourceWork,
|
||||
operator.CalculateResourceQuantity,
|
||||
operator.ConstrainResourceWork,
|
||||
operator.ContractResource,
|
||||
operator.DisableEditingResource,
|
||||
|
||||
@@ -429,3 +429,15 @@ class CalculateResourceUsage(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
core.calculate_resource_usage(tool.Ifc, tool.Resource, resource=tool.Resource.get_highlighted_resource())
|
||||
|
||||
|
||||
class CalculateResourceQuantity(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.calculate_resource_quantity"
|
||||
bl_label = "Calculate Resource Quantity"
|
||||
bl_description = "Calcule resource quantity based on the same name quantities from the output products"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
resource: bpy.props.IntProperty(name="Resource ID")
|
||||
|
||||
def _execute(self, context):
|
||||
core.calculate_resource_quantity(tool.Resource, resource=tool.Ifc.get().by_id(self.resource))
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -258,6 +258,9 @@ class BIM_PT_resources(Panel):
|
||||
else:
|
||||
op = row.operator("bim.enable_editing_resource_quantity", text="", icon="GREASEPENCIL")
|
||||
op.resource = self.props.active_resource_id
|
||||
if resource["type"] == "IfcConstructionMaterialResource":
|
||||
op = row.operator("bim.calculate_resource_quantity", text="", icon="FILE_REFRESH")
|
||||
op.resource = self.props.active_resource_id
|
||||
op = row.operator("bim.remove_resource_quantity", text="", icon="X")
|
||||
op.resource = self.props.active_resource_id
|
||||
|
||||
|
||||
@@ -262,3 +262,7 @@ def calculate_resource_usage(
|
||||
) -> None:
|
||||
ifc.run("resource.calculate_resource_usage", resource=resource)
|
||||
resource_tool.load_resources()
|
||||
|
||||
|
||||
def calculate_resource_quantity(resource_tool: tool.Resource, resource: ifcopenshell.entity_instance) -> None:
|
||||
resource_tool.calculate_resource_quantity(resource)
|
||||
|
||||
@@ -443,6 +443,12 @@ class Resource(bonsai.core.tool.Resource):
|
||||
def run_calculate_resource_usage(cls, resource: ifcopenshell.entity_instance) -> None:
|
||||
tool.Ifc.run("resource.calculate_resource_usage", resource=resource)
|
||||
|
||||
@classmethod
|
||||
def calculate_resource_quantity(cls, resource: ifcopenshell.entity_instance) -> None:
|
||||
quantity: ifcopenshell.entity_instance = resource.BaseQuantity
|
||||
quantity_from_products = ifcopenshell.util.resource.get_total_quantity_produced(resource, quantity.Name)
|
||||
quantity[3] = quantity_from_products
|
||||
|
||||
@classmethod
|
||||
def get_task_assignments(cls, resource: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||
return ifcopenshell.util.resource.get_task_assignments(resource)
|
||||
|
||||
Reference in New Issue
Block a user