diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index b0fa948091..3bac172d59 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -199,6 +199,7 @@ if bpy is not None: operator.AddDrawingStyleAttribute, operator.RemoveDrawingStyleAttribute, operator.CopyPropertyToSelection, + operator.CreateShapeFromStepId, prop.StrProperty, prop.Variable, prop.Role, @@ -227,6 +228,7 @@ if bpy is not None: prop.BcfTopicRelatedTopic, prop.Subcontext, prop.BIMProperties, + prop.BIMDebugProperties, prop.BCFProperties, prop.DocProperties, prop.BIMLibrary, @@ -267,6 +269,7 @@ if bpy is not None: ui.BIM_PT_cobie, ui.BIM_PT_patch, ui.BIM_PT_mvd, + ui.BIM_PT_debug, ui.BIM_PT_material, ui.BIM_PT_mesh, ui.BIM_PT_object, @@ -329,6 +332,7 @@ if bpy is not None: bpy.types.TOPBAR_MT_file_export.append(menu_func_export) bpy.types.TOPBAR_MT_file_import.append(menu_func_import) bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties) + bpy.types.Scene.BIMDebugProperties = bpy.props.PointerProperty(type=prop.BIMDebugProperties) bpy.types.Scene.BCFProperties = bpy.props.PointerProperty(type=prop.BCFProperties) bpy.types.Scene.DocProperties = bpy.props.PointerProperty(type=prop.DocProperties) bpy.types.Scene.BIMLibrary = bpy.props.PointerProperty(type=prop.BIMLibrary) @@ -358,6 +362,7 @@ if bpy is not None: bpy.types.TOPBAR_MT_file_export.remove(menu_func_export) bpy.types.TOPBAR_MT_file_import.remove(menu_func_import) del(bpy.types.Scene.BIMProperties) + del(bpy.types.Scene.BIMDebugProperties) del(bpy.types.Scene.BCFProperties) del(bpy.types.Scene.DocProperties) del(bpy.types.Scene.MapConversion) diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index e9c7b6ae3c..393f0f0bb8 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -3940,3 +3940,23 @@ class RemoveDrawingStyleAttribute(bpy.types.Operator): props = bpy.context.scene.camera.data.BIMCameraProperties context.scene.DocProperties.drawing_styles[props.active_drawing_style_index].attributes.remove(self.index) return {'FINISHED'} + + +class CreateShapeFromStepId(bpy.types.Operator): + bl_idname = 'bim.create_shape_from_step_id' + bl_label = 'Create Shape From STEP ID' + + def execute(self, context): + logger = logging.getLogger('ImportIFC') + self.ifc_import_settings = import_ifc.IfcImportSettings.factory(bpy.context, ifc.IfcStore.path, logger) + self.file = ifc.IfcStore.get_file() + element = self.file.by_id(int(bpy.context.scene.BIMDebugProperties.step_id)) + settings = ifcopenshell.geom.settings() + #settings.set(settings.INCLUDE_CURVES, True) + shape = ifcopenshell.geom.create_shape(settings, element) + ifc_importer = import_ifc.IfcImporter(self.ifc_import_settings) + ifc_importer.file = self.file + mesh = ifc_importer.create_mesh(element, shape) + obj = bpy.data.objects.new('Debug', mesh) + bpy.context.scene.collection.objects.link(obj) + return {'FINISHED'} diff --git a/src/ifcblenderexport/blenderbim/bim/prop.py b/src/ifcblenderexport/blenderbim/bim/prop.py index cb920043d5..300dc0be32 100644 --- a/src/ifcblenderexport/blenderbim/bim/prop.py +++ b/src/ifcblenderexport/blenderbim/bim/prop.py @@ -1351,6 +1351,10 @@ class BIMObjectProperties(PropertyGroup): representation_contexts: CollectionProperty(name="Representation Contexts", type=Subcontext) +class BIMDebugProperties(PropertyGroup): + step_id: IntProperty(name="STEP ID") + + class BIMMaterialProperties(PropertyGroup): is_external: BoolProperty(name="Has External Definition") location: StringProperty(name="Location") diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 0d0b598085..20cc614f85 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -2006,6 +2006,27 @@ class BIM_PT_misc_utilities(Panel): row.operator("bim.set_viewport_shadow_from_sun") +class BIM_PT_debug(Panel): + bl_label = "IFC Debug" + bl_idname = "BIM_PT_debug" + bl_options = {'DEFAULT_CLOSED'} + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "scene" + + def draw(self, context): + layout = self.layout + + scene = context.scene + bim_props = scene.BIMProperties + debug_props = scene.BIMDebugProperties + + row = layout.row() + row.prop(debug_props, 'step_id', text='') + row = layout.row() + row.operator('bim.create_shape_from_step_id') + + def ifc_units(self, context): scene = context.scene props = context.scene.BIMProperties