diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index c8eb044012..bc9e1c4984 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -400,6 +400,12 @@ class IfcImporter: items = representation["raw"].Items or [] # Be forgiving of invalid IFCs because Revit :( if len(items) == 1 and items[0].is_a("IfcSweptDiskSolid"): return True + elif ( + items[0].is_a("IfcSweptDiskSolid") + and len({i.is_a() for i in items}) == 1 + and len({i.Radius for i in items}) == 1 + ): + return True return False def is_native_faceted_brep(self, representations): diff --git a/src/blenderbim/blenderbim/bim/module/group/__init__.py b/src/blenderbim/blenderbim/bim/module/group/__init__.py index bc16858fd2..8dda1b596b 100644 --- a/src/blenderbim/blenderbim/bim/module/group/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/group/__init__.py @@ -20,19 +20,18 @@ import bpy from . import ui, prop, operator classes = ( - operator.LoadGroups, - operator.ToggleGroup, - operator.DisableGroupEditingUI, operator.AddGroup, - operator.AddGroupToGroup, - operator.EditGroup, - operator.RemoveGroup, - operator.ToggleAssigningGroup, operator.AssignGroup, - operator.UnassignGroup, - operator.EnableEditingGroup, operator.DisableEditingGroup, + operator.DisableGroupEditingUI, + operator.EditGroup, + operator.EnableEditingGroup, + operator.LoadGroups, + operator.RemoveGroup, operator.SelectGroupProducts, + operator.ToggleAssigningGroup, + operator.ToggleGroup, + operator.UnassignGroup, operator.UpdateGroup, prop.ExpandedGroups, prop.Group, diff --git a/src/blenderbim/blenderbim/bim/module/group/operator.py b/src/blenderbim/blenderbim/bim/module/group/operator.py index 6b7f7cfc0f..70a5eb927e 100644 --- a/src/blenderbim/blenderbim/bim/module/group/operator.py +++ b/src/blenderbim/blenderbim/bim/module/group/operator.py @@ -20,6 +20,7 @@ import bpy import ifcopenshell.util.attribute import ifcopenshell.api import blenderbim.bim.helper +import blenderbim.tool as tool from blenderbim.bim.ifc import IfcStore from ifcopenshell.api.group.data import Data from ifcopenshell.util.selector import Selector @@ -120,37 +121,19 @@ class AddGroup(bpy.types.Operator): bl_idname = "bim.add_group" bl_label = "Add New Group" bl_options = {"REGISTER", "UNDO"} + group: bpy.props.IntProperty() def execute(self, context): return IfcStore.execute_ifc_operator(self, context) def _execute(self, context): - result = ifcopenshell.api.run("group.add_group", IfcStore.get_file()) - Data.load(IfcStore.get_file()) - + result = ifcopenshell.api.run("group.add_group", tool.Ifc.get()) + if self.group: + ifcopenshell.api.run( + "group.assign_group", tool.Ifc.get(), products=[result], group=tool.Ifc.get().by_id(self.group) + ) + Data.load(tool.Ifc.get()) bpy.ops.bim.load_groups(is_refresh=True) - bpy.ops.bim.enable_editing_group(group=result.id()) - return {"FINISHED"} - - -class AddGroupToGroup(bpy.types.Operator): - bl_idname = "bim.add_group_to_group" - bl_label = "Add Group to Group" - bl_options = {"REGISTER", "UNDO"} - group: bpy.props.IntProperty(name="Group ID") - - def execute(self, context): - return IfcStore.execute_ifc_operator(self, context) - - def _execute(self, context): - self.file = IfcStore.get_file() - result = ifcopenshell.api.run("group.add_group", self.file) - ifcopenshell.api.run( - "group.assign_group", IfcStore.get_file(), products=[result], group=self.file.by_id(self.group) - ) - Data.load(IfcStore.get_file()) - bpy.ops.bim.load_groups(is_refresh=True) - bpy.ops.bim.disable_group_editing_ui() return {"FINISHED"} diff --git a/src/blenderbim/blenderbim/bim/module/group/ui.py b/src/blenderbim/blenderbim/bim/module/group/ui.py index 0f75e09097..0f293e54b8 100644 --- a/src/blenderbim/blenderbim/bim/module/group/ui.py +++ b/src/blenderbim/blenderbim/bim/module/group/ui.py @@ -42,7 +42,7 @@ class BIM_PT_groups(Panel): row = self.layout.row(align=True) row.label(text=f"{len(Data.groups)} Groups Found", icon="OUTLINER") if self.props.is_editing: - row.operator("bim.add_group", text="", icon="ADD") + row.operator("bim.add_group", text="", icon="ADD").group = 0 row.operator("bim.disable_group_editing_ui", text="", icon="CANCEL") else: row.operator("bim.load_groups", text="", icon="GREASEPENCIL") @@ -140,7 +140,7 @@ class BIM_UL_groups(UIList): elif context.scene.BIMGroupProperties.active_group_id: op = row.operator("bim.select_group_products", text="", icon="RESTRICT_SELECT_OFF") op.group = group_id - op = row.operator("bim.add_group_to_group", text="", icon="ADD") + op = row.operator("bim.add_group", text="", icon="ADD") op.group = group_id op = row.operator("bim.remove_group", text="", icon="X") op.group = group_id @@ -153,7 +153,7 @@ class BIM_UL_groups(UIList): op.group = group_id op = row.operator("bim.enable_editing_group", text="", icon="GREASEPENCIL") op.group = group_id - op = row.operator("bim.add_group_to_group", text="", icon="ADD") + op = row.operator("bim.add_group", text="", icon="ADD") op.group = group_id op = row.operator("bim.remove_group", text="", icon="X") op.group = group_id diff --git a/src/blenderbim/scripts/obj2ifc-meshlab.py b/src/blenderbim/scripts/obj2ifc-meshlab.py index 81479fca41..b41ebd3930 100644 --- a/src/blenderbim/scripts/obj2ifc-meshlab.py +++ b/src/blenderbim/scripts/obj2ifc-meshlab.py @@ -25,6 +25,7 @@ import ifcopenshell.api import ifcopenshell.api.owner.settings from pathlib import Path +import numpy as np class Obj2Ifc: def __init__(self, path): @@ -44,9 +45,10 @@ class Obj2Ifc: faces = mesh.face_matrix() vertices = mesh.vertex_matrix() - ifc_faces = [] - for face in faces: - ifc_faces.append( + + ifc_faces = np.zeros([len(faces)], dtype=object) + for i, face in enumerate(faces): + ifc_faces[i] = ( self.file.createIfcFace( [ self.file.createIfcFaceOuterBound( @@ -71,7 +73,7 @@ class Obj2Ifc: self.context, "Body", "Brep", - [self.file.createIfcFacetedBrep(self.file.createIfcClosedShell(ifc_faces))], + [self.file.createIfcFacetedBrep(self.file.createIfcClosedShell(ifc_faces.tolist()))], ) ], ) 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])