From e354354b1ae2669685bf1b18d3da94beb981228d Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 30 Jan 2020 15:33:01 +1100 Subject: [PATCH] Fix curve profile orientation on export. --- src/ifcblenderexport/blenderbim/export_ifc.py | 24 +++++++++++-------- src/ifcblenderexport/blenderbim/prop.py | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/ifcblenderexport/blenderbim/export_ifc.py b/src/ifcblenderexport/blenderbim/export_ifc.py index 9005959f90..1655d350ac 100644 --- a/src/ifcblenderexport/blenderbim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/export_ifc.py @@ -1947,12 +1947,17 @@ class IfcExporter(): self.create_curve(representation['raw'].bevel_object.data)) swept_area_solids = [] for spline in representation['raw'].splines: - direction = spline.bezier_points[1].co - spline.bezier_points[0].co + points = self.get_spline_points(spline) + if not points: + continue + # Intuitively, the direction below is reversed, but apparently + # Blender likes to extrude down (opposite of IFC) natively. + direction = (points[0].co - points[1].co).xyz unit_direction = direction.normalized() # This can be used in the future when dealing with non vector curves - # curr_point = spline.bezier_points[0] - # next_point = spline.bezier_points[1] + # curr_point = points[0] + # next_point = points[1] # j_percent = 0 # direction = self.bezier_tangent( # pt0=curr_point.co, @@ -1960,11 +1965,10 @@ class IfcExporter(): # pt2=next_point.handle_left, # pt3=next_point.co, # step=j_percent) - tilt_matrix = Matrix.Rotation(-spline.bezier_points[0].tilt, 4, 'Z') + tilt_matrix = Matrix.Rotation(points[0].tilt, 4, 'Z') x_axis = unit_direction.to_track_quat('-Y', 'Z') @ Vector((1, 0, 0)) @ tilt_matrix - position = self.create_ifc_axis_2_placement_3d( - spline.bezier_points[0].co, unit_direction, x_axis) + points[1].co, unit_direction, x_axis) swept_area_solids.append(self.file.createIfcExtrudedAreaSolid( swept_area, position, self.file.createIfcDirection((0., 0., 1.)), @@ -1983,11 +1987,11 @@ class IfcExporter(): return self.file.createIfcVertexPoint( self.create_cartesian_point(point.x, point.y, point.z)) + def get_spline_points(self, spline): + return spline.bezier_points if spline.bezier_points else spline.points + def create_edge(self, curve): - if curve.splines[0].bezier_points: - points = curve.splines[0].bezier_points - elif curve.splines[0].points: - points = curve.splines[0].points + points = self.get_spline_points(curve.splines[0]) if not points: return return self.file.createIfcEdge( diff --git a/src/ifcblenderexport/blenderbim/prop.py b/src/ifcblenderexport/blenderbim/prop.py index 88b03bcea6..359e6b7740 100644 --- a/src/ifcblenderexport/blenderbim/prop.py +++ b/src/ifcblenderexport/blenderbim/prop.py @@ -67,7 +67,8 @@ def getIfcPredefinedTypes(self, context): def refreshClasses(self, context): global classes_enum classes_enum.clear() - getIfcClasses(self, context) + enum = getIfcClasses(self, context) + context.scene.BIMProperties.ifc_class = enum[0][0] def refreshPredefinedTypes(self, context):