diff --git a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py index cbab82e81d..d7a357cc69 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py +++ b/src/ifcopenshell-python/ifcopenshell/api/geometry/add_representation.py @@ -217,7 +217,9 @@ class Usecase: ) def create_variable_representation(self): - if isinstance(self.settings["geometry"], bpy.types.Curve): + if isinstance(self.settings["geometry"], bpy.types.Curve) and self.settings["geometry"].bevel_depth: + return self.create_swept_disk_solid_representation() + elif isinstance(self.settings["geometry"], bpy.types.Curve): return self.create_curve3d_representation() elif isinstance(self.settings["geometry"], bpy.types.Camera): return self.create_camera_block_representation() @@ -273,6 +275,14 @@ class Usecase: > self.settings["geometry"].BIMCameraProperties.raster_y ) + def create_swept_disk_solid_representation(self): + return self.file.createIfcShapeRepresentation( + self.settings["context"], + self.settings["context"].ContextIdentifier, + "AdvancedSweptSolid", + self.create_swept_disk_solids(), + ) + def create_curve3d_representation(self): return self.file.createIfcShapeRepresentation( self.settings["context"], @@ -335,6 +345,14 @@ class Usecase: ] return self.file.createIfcPolyline([points[i] for i in indices]) + def create_swept_disk_solids(self): + curves = self.create_curves() + results = [] + radius = self.convert_si_to_unit(round(self.settings["geometry"].bevel_depth, 3)) + for curve in curves: + results.append(self.file.createIfcSweptDiskSolid(curve, radius)) + return results + def create_curves(self, should_exclude_faces=False, is_2d=False): if isinstance(self.settings["geometry"], bpy.types.Mesh): if self.file.schema == "IFC2X3": diff --git a/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py b/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py index 80f82e46f5..55da846050 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py +++ b/src/ifcopenshell-python/ifcopenshell/api/style/assign_representation_styles.py @@ -38,7 +38,9 @@ class Usecase: for item in element.Items: if not item.is_a("IfcGeometricRepresentationItem"): continue - style = self.settings["styles"].pop(0) + if self.settings["styles"]: + # If there are more items than styles, fallback to using the last style + style = self.settings["styles"].pop(0) name = style.Name if self.file.schema == "IFC2X3" or self.settings["should_use_presentation_style_assignment"]: style = self.file.createIfcPresentationStyleAssignment([style])