mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
Notify user if duration parsing not available in util.date
This commit is contained in:
@@ -56,10 +56,6 @@ def add_resource_time(file: ifcopenshell.file, resource: ifcopenshell.entity_ins
|
|||||||
ifcopenshell.api.run("resource.edit_resource_time", model,
|
ifcopenshell.api.run("resource.edit_resource_time", model,
|
||||||
resource_time=time, attributes={"ScheduleWork": "PT16H"})
|
resource_time=time, attributes={"ScheduleWork": "PT16H"})
|
||||||
"""
|
"""
|
||||||
settings = {
|
|
||||||
"resource": resource,
|
|
||||||
}
|
|
||||||
|
|
||||||
resource_time = file.create_entity("IfcResourceTime")
|
resource_time = file.create_entity("IfcResourceTime")
|
||||||
settings["resource"].Usage = resource_time
|
resource.Usage = resource_time
|
||||||
return resource_time
|
return resource_time
|
||||||
|
|||||||
@@ -56,17 +56,15 @@ def calculate_resource_work(file: ifcopenshell.file, resource: ifcopenshell.enti
|
|||||||
:return None:
|
:return None:
|
||||||
:rtype: None:
|
:rtype: None:
|
||||||
"""
|
"""
|
||||||
settings = {"resource": resource}
|
if ifcopenshell.util.constraint.is_attribute_locked(resource, "Usage.ScheduleWork"):
|
||||||
|
|
||||||
if ifcopenshell.util.constraint.is_attribute_locked(settings["resource"], "Usage.ScheduleWork"):
|
|
||||||
return
|
return
|
||||||
amount_worked = ifcopenshell.util.resource.get_resource_required_work(settings["resource"])
|
amount_worked = ifcopenshell.util.resource.get_resource_required_work(resource)
|
||||||
if not amount_worked:
|
if not amount_worked:
|
||||||
return
|
return
|
||||||
if not settings["resource"].Usage:
|
if not resource.Usage:
|
||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"resource.add_resource_time",
|
"resource.add_resource_time",
|
||||||
file,
|
file,
|
||||||
resource=settings["resource"],
|
resource=resource,
|
||||||
)
|
)
|
||||||
settings["resource"].Usage.ScheduleWork = amount_worked
|
resource.Usage.ScheduleWork = amount_worked
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ from dateutil import parser
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import isodate
|
import isodate
|
||||||
except:
|
except ModuleNotFoundError as e:
|
||||||
pass # Duration parsing not supported
|
print(f"Note: duration parsing not available due to missing dependencies: util.date - {e}")
|
||||||
|
|
||||||
|
|
||||||
def timedelta2duration(timedelta):
|
def timedelta2duration(timedelta):
|
||||||
@@ -187,8 +187,6 @@ def parse_duration(value):
|
|||||||
if "P" in value:
|
if "P" in value:
|
||||||
try:
|
try:
|
||||||
return isodate.parse_duration(value)
|
return isodate.parse_duration(value)
|
||||||
except ModuleNotFoundError:
|
|
||||||
print("Duration parsing not supported: isodate module not found")
|
|
||||||
except:
|
except:
|
||||||
print("Error parsing ISO string duration")
|
print("Error parsing ISO string duration")
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user