mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
Fix #2698. IfcClash results are now aware of multiple linked IFC models.
This commit is contained in:
@@ -51,6 +51,7 @@ class IfcStore:
|
|||||||
history = []
|
history = []
|
||||||
future = []
|
future = []
|
||||||
schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
||||||
|
session_files = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge():
|
||||||
@@ -71,6 +72,7 @@ class IfcStore:
|
|||||||
IfcStore.history = []
|
IfcStore.history = []
|
||||||
IfcStore.future = []
|
IfcStore.future = []
|
||||||
IfcStore.schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
IfcStore.schema_identifiers = ["IFC4", "IFC2X3", "IFC4X3"]
|
||||||
|
IfcStore.session_files = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_file():
|
def get_file():
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import json
|
|||||||
import bmesh
|
import bmesh
|
||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import ifcopenshell
|
||||||
from mathutils import Matrix
|
from mathutils import Matrix
|
||||||
from math import radians
|
from math import radians
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
@@ -32,6 +33,7 @@ class ExportClashSets(bpy.types.Operator):
|
|||||||
bl_label = "Export Clash Sets"
|
bl_label = "Export Clash Sets"
|
||||||
filename_ext = ".json"
|
filename_ext = ".json"
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
||||||
@@ -64,6 +66,7 @@ class ImportClashSets(bpy.types.Operator):
|
|||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
filename_ext = ".json"
|
filename_ext = ".json"
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json")
|
||||||
@@ -194,7 +197,7 @@ class SelectSmartGroupedClashesPath(bpy.types.Operator):
|
|||||||
class ExecuteIfcClash(bpy.types.Operator):
|
class ExecuteIfcClash(bpy.types.Operator):
|
||||||
bl_idname = "bim.execute_ifc_clash"
|
bl_idname = "bim.execute_ifc_clash"
|
||||||
bl_label = "Execute IFC Clash"
|
bl_label = "Execute IFC Clash"
|
||||||
filter_glob: bpy.props.StringProperty( default='*.bcf;*.json', options={'HIDDEN'} )
|
filter_glob: bpy.props.StringProperty(default="*.bcf;*.json", options={"HIDDEN"})
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
@@ -287,10 +290,25 @@ class SelectIfcClashResults(bpy.types.Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
for clash in clash_set["clashes"].values():
|
for clash in clash_set["clashes"].values():
|
||||||
global_ids.extend([clash["a_global_id"], clash["b_global_id"]])
|
global_ids.extend([clash["a_global_id"], clash["b_global_id"]])
|
||||||
|
|
||||||
for obj in context.visible_objects:
|
for obj in context.visible_objects:
|
||||||
if not obj.BIMObjectProperties.ifc_definition_id:
|
if not obj.BIMObjectProperties.ifc_definition_id:
|
||||||
continue
|
continue
|
||||||
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
|
||||||
|
ifc_file = ""
|
||||||
|
for scene in obj.users_scene:
|
||||||
|
if scene.BIMProperties.ifc_file:
|
||||||
|
ifc_file = scene.BIMProperties.ifc_file
|
||||||
|
break
|
||||||
|
|
||||||
|
if ifc_file:
|
||||||
|
if ifc_file not in IfcStore.session_files:
|
||||||
|
IfcStore.session_files[ifc_file] = ifcopenshell.open(ifc_file)
|
||||||
|
element_file = IfcStore.session_files[ifc_file]
|
||||||
|
else:
|
||||||
|
element_file = self.file
|
||||||
|
|
||||||
|
element = element_file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
if element.GlobalId in global_ids:
|
if element.GlobalId in global_ids:
|
||||||
obj.select_set(True)
|
obj.select_set(True)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
Reference in New Issue
Block a user