This commit is contained in:
Andrej730
2024-11-11 11:56:37 +05:00
parent 088bc207ab
commit 004488533f
5 changed files with 18 additions and 23 deletions
@@ -151,7 +151,7 @@ class UpdateIfcPatchArguments(bpy.types.Operator):
new_attr.set_value(arg_info.get("default", new_attr.get_value_default()))
return {"FINISHED"}
def pretty_arg_name(self, arg_name: str):
def pretty_arg_name(self, arg_name: str) -> str:
words = []
for word in arg_name.split("_"):
+8 -15
View File
@@ -23,6 +23,7 @@ import ifcopenshell.util.constraint
import ifcopenshell.util.cost
import ifcopenshell.util.date
import ifcopenshell.util.resource
from typing import Any
def refresh():
@@ -44,11 +45,11 @@ class ResourceData:
cls.is_loaded = True
@classmethod
def total_resources(cls):
def total_resources(cls) -> int:
return len(tool.Ifc.get().by_type("IfcResource"))
@classmethod
def resources(cls):
def resources(cls) -> dict[int, dict[str, Any]]:
results = {}
for resource in tool.Ifc.get().by_type("IfcResource"):
base_quantity = None
@@ -63,7 +64,7 @@ class ResourceData:
if resource.is_a() in ["IfcLaborResource", "IfcConstructionEquipmentResource"]:
results[resource.id()]["Productivity"] = {}
results[resource.id()]["InheritedProductivity"] = {}
productivity = cls.get_productivity(resource)
productivity = ifcopenshell.util.resource.get_productivity(resource, should_inherit=False)
if productivity:
results[resource.id()]["Productivity"] = {
"id": productivity.get("id"),
@@ -71,7 +72,7 @@ class ResourceData:
"TimeConsumed": ifcopenshell.util.resource.get_unit_consumed(productivity),
"QuantityProducedName": ifcopenshell.util.resource.get_quantity_produced_name(productivity),
}
inherited_productivity = cls.get_parent_productivity(resource)
inherited_productivity = ifcopenshell.util.resource.get_parent_productivity(resource)
if inherited_productivity:
results[resource.id()]["InheritedProductivity"] = {
"QuantityProduced": ifcopenshell.util.resource.get_quantity_produced(inherited_productivity),
@@ -94,7 +95,7 @@ class ResourceData:
return results
@classmethod
def sum_person_hours(cls, resource):
def sum_person_hours(cls, resource: ifcopenshell.entity_instance) -> float:
sum = 0
nested_resources = ifcopenshell.util.resource.get_nested_resources(resource)
for nested_resource in nested_resources or []:
@@ -105,7 +106,7 @@ class ResourceData:
return round(float(sum), 2) if sum else 0
@classmethod
def get_resource_benchmarks(cls, resource):
def get_resource_benchmarks(cls, resource: ifcopenshell.entity_instance) -> list[dict[str, Any]]:
constraints = []
for constraint in ifcopenshell.util.constraint.get_constraints(resource) or []:
metrics = []
@@ -121,15 +122,7 @@ class ResourceData:
return constraints
@classmethod
def get_productivity(cls, resource):
return ifcopenshell.util.resource.get_productivity(resource, should_inherit=False)
@classmethod
def get_parent_productivity(cls, resource):
return ifcopenshell.util.resource.get_parent_productivity(resource)
@classmethod
def cost_values(cls):
def cost_values(cls) -> list[dict[str, Any]]:
results = []
ifc_id = bpy.context.scene.BIMResourceProperties.active_resource_id
if not ifc_id:
+2 -2
View File
@@ -176,14 +176,14 @@ class MultipleFileSelect(PropertyGroup):
single_file: bpy.props.StringProperty(name="Single File Path", description="", update=update_single_file)
file_list: bpy.props.CollectionProperty(type=StrProperty)
def set_file_list(self, dirname: str, files: list[str]):
def set_file_list(self, dirname: str, files: list[str]) -> None:
self.file_list.clear()
for f in files:
new = self.file_list.add()
new.name = os.path.join(dirname, f)
def layout_file_select(self, layout, filter_glob="", text=""):
def layout_file_select(self, layout: bpy.types.UILayout, filter_glob: str = "", text: str = "") -> None:
if len(self.file_list) > 1:
layout.label(text=f"{len(self.file_list)} Files Selected")
else: