From 63f578315ddec3b99fd795d061de1605becd4350 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 13 Jul 2021 18:45:07 +1000 Subject: [PATCH] Add support for 3D curve / wireframe representations. --- .../bim/module/geometry/operator.py | 54 ++++++++++--------- .../api/geometry/add_representation.py | 8 ++- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index fccaec2288..0d2bc7a63d 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -117,19 +117,20 @@ class AddRepresentation(bpy.types.Operator): if s.material and not s.material.BIMMaterialProperties.ifc_style_id ] - ifcopenshell.api.run( - "style.assign_representation_styles", - self.file, - **{ - "shape_representation": result, - "styles": [ - self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) - for s in obj.material_slots - if s.material - ], - "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, - }, - ) + if isinstance(obj.data, bpy.types.Mesh) and len(obj.data.polygons): + ifcopenshell.api.run( + "style.assign_representation_styles", + self.file, + **{ + "shape_representation": result, + "styles": [ + self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) + for s in obj.material_slots + if s.material + ], + "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, + }, + ) ifcopenshell.api.run( "geometry.assign_representation", self.file, **{"product": product, "representation": result} ) @@ -330,19 +331,20 @@ class UpdateRepresentation(bpy.types.Operator): if s.material and not s.material.BIMMaterialProperties.ifc_style_id ] - ifcopenshell.api.run( - "style.assign_representation_styles", - self.file, - **{ - "shape_representation": new_representation, - "styles": [ - self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) - for s in obj.material_slots - if s.material - ], - "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, - }, - ) + if isinstance(obj.data, bpy.types.Mesh) and len(obj.data.polygons): + ifcopenshell.api.run( + "style.assign_representation_styles", + self.file, + **{ + "shape_representation": new_representation, + "styles": [ + self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id) + for s in obj.material_slots + if s.material + ], + "should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment, + }, + ) # TODO: move this into a replace_representation usecase or something for inverse in self.file.get_inverse(old_representation): diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index 53be859417..16896a254e 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -22,8 +22,6 @@ class Usecase: "unit_scale": None, # A scale factor to apply for all vectors in case the unit is different "should_force_faceted_brep": False, # If we should force faceted breps for meshes "should_force_triangulation": False, # If we should force triangulation for meshes - "is_wireframe": False, # If the geometry is a wireframe - "is_curve": False, # If the geometry is a Blender curve "is_point_cloud": False, # If the geometry is a point cloud # Possible IFC representation classes: # IfcExtrudedAreaSolid/IfcRectangleProfileDef @@ -204,9 +202,9 @@ class Usecase: ) def create_variable_representation(self): - if self.settings["is_wireframe"]: - return self.create_wireframe_representation() - elif self.settings["is_curve"]: + if isinstance(self.settings["geometry"], bpy.types.Curve): + return self.create_curve3d_representation() + elif not len(self.settings["geometry"].polygons): return self.create_curve3d_representation() elif self.settings["is_point_cloud"]: return self.create_point_cloud_representation()