mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +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.AddProductivityData,
|
||||||
operator.AssignResource,
|
operator.AssignResource,
|
||||||
operator.CalculateResourceWork,
|
operator.CalculateResourceWork,
|
||||||
|
operator.CalculateResourceQuantity,
|
||||||
operator.ConstrainResourceWork,
|
operator.ConstrainResourceWork,
|
||||||
operator.ContractResource,
|
operator.ContractResource,
|
||||||
operator.DisableEditingResource,
|
operator.DisableEditingResource,
|
||||||
|
|||||||
@@ -429,3 +429,15 @@ class CalculateResourceUsage(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
def _execute(self, context):
|
def _execute(self, context):
|
||||||
core.calculate_resource_usage(tool.Ifc, tool.Resource, resource=tool.Resource.get_highlighted_resource())
|
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:
|
else:
|
||||||
op = row.operator("bim.enable_editing_resource_quantity", text="", icon="GREASEPENCIL")
|
op = row.operator("bim.enable_editing_resource_quantity", text="", icon="GREASEPENCIL")
|
||||||
op.resource = self.props.active_resource_id
|
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 = row.operator("bim.remove_resource_quantity", text="", icon="X")
|
||||||
op.resource = self.props.active_resource_id
|
op.resource = self.props.active_resource_id
|
||||||
|
|
||||||
|
|||||||
@@ -262,3 +262,7 @@ def calculate_resource_usage(
|
|||||||
) -> None:
|
) -> None:
|
||||||
ifc.run("resource.calculate_resource_usage", resource=resource)
|
ifc.run("resource.calculate_resource_usage", resource=resource)
|
||||||
resource_tool.load_resources()
|
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:
|
def run_calculate_resource_usage(cls, resource: ifcopenshell.entity_instance) -> None:
|
||||||
tool.Ifc.run("resource.calculate_resource_usage", resource=resource)
|
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
|
@classmethod
|
||||||
def get_task_assignments(cls, resource: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
def get_task_assignments(cls, resource: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
return ifcopenshell.util.resource.get_task_assignments(resource)
|
return ifcopenshell.util.resource.get_task_assignments(resource)
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ def calculate_cost_item_resource_value(file: ifcopenshell.file, cost_item: ifcop
|
|||||||
|
|
||||||
for resource in resources:
|
for resource in resources:
|
||||||
cost, unit = ifcopenshell.util.resource.get_cost(resource)
|
cost, unit = ifcopenshell.util.resource.get_cost(resource)
|
||||||
|
# TODO: cost is never None because get_cost always returns a float.
|
||||||
if cost is None:
|
if cost is None:
|
||||||
# Concept to standardise - Not defined in schema, but this makes manual scheduling of resources 10x faster and less duplicate data.
|
# Concept to standardise - Not defined in schema, but this makes manual scheduling of resources 10x faster and less duplicate data.
|
||||||
parent_cost = ifcopenshell.util.resource.get_parent_cost(resource)
|
parent_cost = ifcopenshell.util.resource.get_parent_cost(resource)
|
||||||
|
|||||||
Reference in New Issue
Block a user