From 153b6ee24d302aa73319e4e0c1858e613bc3d774 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 4 Jun 2021 17:22:35 +1000 Subject: [PATCH] Total float calculation now takes into account calendar --- .../api/geometry/add_representation.py | 17 +++++++---------- .../api/sequence/recalculate_schedule.py | 9 ++++++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index 75ac4a361b..069498a4c1 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -49,7 +49,7 @@ class Usecase: elif self.settings["context"].ContextType == "Plan": return self.create_plan_representation() return self.create_variable_representation() - + def should_triangulate_face(self, face, threshold=EPSILON): vz = face.normal co = face.verts[0].co @@ -60,15 +60,12 @@ class Usecase: else: vx = vz.cross(X_AXIS) vy = vx.cross(vz) - tM = Matrix([ - [vx.x, vy.x, vz.x, co.x], - [vx.y, vy.y, vz.y, co.y], - [vx.z, vy.z, vz.z, co.z], - [0, 0, 0, 1] - ]).inverted() + tM = Matrix( + [[vx.x, vy.x, vz.x, co.x], [vx.y, vy.y, vz.y, co.y], [vx.z, vy.z, vz.z, co.z], [0, 0, 0, 1]] + ).inverted() + + return any([abs((tM @ v.co).z) > threshold for v in face.verts]) - return any([abs((tM @ v.co).z) > threshold for v in face.verts]) - def evaluate_geometry(self): for modifier in self.settings["blender_object"].modifiers: if modifier.type == "BOOLEAN": @@ -265,7 +262,7 @@ class Usecase: "Curve3D", self.create_curves(), ) - + def create_curve2d_representation(self): return self.file.createIfcShapeRepresentation( self.settings["context"], diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py index abcecfe8f7..cbec778d69 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/recalculate_schedule.py @@ -242,7 +242,14 @@ class Usecase: elif data.get("late_start") is None: data["late_start"] = self.offset_date(data["late_finish"], -data["duration"], data) - data["total_float"] = data["late_finish"] - data["early_finish"] + if data["duration_type"] == "WORKTIME": + data["total_float"] = datetime.timedelta( + days=ifcopenshell.util.sequence.count_working_days( + data["early_finish"], data["late_finish"], data["calendar"] + ) + ) + else: + data["total_float"] = data["late_finish"] - data["early_finish"] # Waiting for yassine to confirm relationships # data["free_float"] = min([self.g.nodes[s]["early_start"] for s in successors])