From 6d26e1c31f0ef0b4b23db8e327d375f173f1cf98 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 27 Apr 2020 14:30:33 +1000 Subject: [PATCH] Add support for BCF clipping planes --- .../blenderbim/bim/operator.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index ed9d620eb8..e0cbf65b92 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -474,6 +474,10 @@ class ActivateBcfViewpoint(bpy.types.Operator): if viewpoint.lines: self.draw_lines(viewpoint) + self.delete_clipping_planes() + if viewpoint.clippingPlanes: + self.create_clipping_planes(viewpoint) + z_axis = Vector((-camera.direction.x, -camera.direction.y, -camera.direction.z)).normalized() y_axis = Vector((camera.upVector.x, camera.upVector.y, camera.upVector.z)).normalized() x_axis = y_axis.cross(z_axis).normalized() @@ -531,6 +535,29 @@ class ActivateBcfViewpoint(bpy.types.Operator): coords.extend([l.start.x, l.start.y, l.start.z, l.end.x, l.end.y, l.end.z]) stroke.points.foreach_set('co', coords) + def create_clipping_planes(self, viewpoint): + n = 0 + for plane in viewpoint.clippingPlanes: + bpy.ops.bim.add_section_plane() + if n == 0: + obj = bpy.data.objects['Section'] + else: + obj = bpy.data.objects['Section.{:03d}'.format(n)] + obj.location = (plane.location.x, plane.location.y, plane.location.z) + obj.rotation_mode = 'QUATERNION' + obj.rotation_quaternion = Vector( + (plane.direction.x, plane.direction.y, plane.direction.z) + ).to_track_quat('Z', 'Y') + n += 1 + + def delete_clipping_planes(self): + collection = bpy.data.collections.get('Sections') + if not collection: + return + for section in collection.objects: + bpy.context.view_layer.objects.active = section + bpy.ops.bim.remove_section_plane() + def hex_to_rgb(self, value): value = value.lstrip('#') lv = len(value)