Compare commits

...

6 Commits

Author SHA1 Message Date
Ryan Schultz ace1b56467 Space_at_origin_warning 2025-11-26 17:38:39 -06:00
Bruno Postle a675365dfd Correct fix for OCC built with VTK support 2025-11-26 22:53:38 +00:00
Bruno Postle 5ab6deb121 Revert cbd2689 Propagate CMP0167 policy 2025-11-25 23:08:52 +00:00
Bruno Postle cbd26896ba Propagate CMP0167 policy to fix cmake warnings 2025-11-25 18:45:59 +00:00
Bruno Postle ceeca752ea Fix build error from OCC with VTK support
OpenCASCADE may be built with VTK support. Try to find VTK first to avoid
CMake errors when OpenCASCADE's config references VTK targets.
2025-11-25 18:44:32 +00:00
Thomas Krijnen 9d437b5bc3 Mark simple type instance file ownership #7226 2025-11-25 09:19:28 +01:00
4 changed files with 69 additions and 0 deletions
+5
View File
@@ -29,6 +29,11 @@ if(NOT OCC_INCLUDE_DIR AND NOT OCC_LIBRARY_DIR)
# find_package creates variables:
# - `OpenCASCADE_INCLUDE_DIR`
# - `OpenCASCADE_LIBRARIES`
# OpenCASCADE may be built with VTK support. Try to find VTK first to avoid
# CMake errors when OpenCASCADE's config references VTK targets.
find_package(VTK QUIET)
find_package(OpenCASCADE CONFIG REQUIRED)
return()
endif()
@@ -20,6 +20,7 @@ import bpy
from . import ui, prop, operator, workspace, gizmo, decorator
classes = (
operator.WM_OT_space_origin_warning,
operator.AddProjectLibrary,
operator.AppendEntireLibrary,
operator.AppendInspectedLinkedElement,
@@ -87,6 +88,7 @@ classes = (
ui.BIM_UL_filter_categories,
ui.BIM_UL_links,
gizmo.ClippingPlane,
)
addon_keymaps = []
@@ -74,6 +74,38 @@ if TYPE_CHECKING:
PresetType = Literal["metric_m", "metric_mm", "imperial_ft", "demo", "wizard"]
class WM_OT_space_origin_warning(bpy.types.Operator):
"""Warning dialog for spaces at origin"""
bl_idname = "wm.space_origin_warning"
bl_label = "Space Origin Warning"
bl_options = {'INTERNAL'}
message: bpy.props.StringProperty()
space_count: bpy.props.IntProperty()
def execute(self, context):
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=400)
def draw(self, context):
layout = self.layout
layout.alert = True
box = layout.box()
col = box.column(align=True)
col.label(text=f"⚠️ WARNING: {self.space_count} IfcSpace(s) at origin (0,0,0)!", icon='ERROR')
col.separator()
for line in self.message.split('\n'):
if line.strip():
col.label(text=line)
col.separator()
col.label(text="This may indicate incorrect placement.")
class NewProject(bpy.types.Operator):
bl_idname = "bim.new_project"
bl_label = "New Project"
@@ -1679,6 +1711,31 @@ class ExportIFC(bpy.types.Operator, ExportHelper):
settings.json_version = self.json_version
settings.json_compact = self.json_compact
# CHECK FOR SPACES AT ORIGIN
ifc_file = tool.Ifc.get()
spaces_at_origin = []
for space in ifc_file.by_type("IfcSpace"):
obj = tool.Ifc.get_object(space)
if obj and all(abs(coord) < 0.001 for coord in obj.location):
spaces_at_origin.append(space.Name or space.GlobalId)
if spaces_at_origin:
# Build message
message_lines = [f"{name}" for name in spaces_at_origin[:5]]
if len(spaces_at_origin) > 5:
message_lines.append(f" ... and {len(spaces_at_origin) - 5} more")
message = '\n'.join(message_lines)
# Show dialog - user MUST click OK
bpy.ops.wm.space_origin_warning('INVOKE_DEFAULT',
message=message,
space_count=len(spaces_at_origin))
self.report({'WARNING'}, f"⚠️ {len(spaces_at_origin)} IfcSpace(s) at origin!")
ifc_exporter = export_ifc.IfcExporter(settings)
print("Starting export")
settings.logger.info("Starting export")
+5
View File
@@ -1607,6 +1607,11 @@ void IfcParse::impl::in_memory_file_storage::read_from_stream(IfcParse::FileRead
// Move the storage of simple type instances so that they are retained during the lifetime of the file
read_simple_type_instances = streamer.stealInstances();
// Set file ownership on simple type instances, so that when adding them to other files, proper copies are created
for (auto& inst : read_simple_type_instances) {
inst->file_ = file;
}
Logger::Status("\rDone scanning file ");
delete tokens;