@@ -30,6 +30,9 @@ def name_callback(obj, data):
3030 element = IfcStore .get_file ().by_id (obj .BIMObjectProperties .ifc_definition_id )
3131 if not element .is_a ("IfcRoot" ):
3232 return
33+ if element .is_a ("IfcSpatialStructureElement" ) or (hasattr (element , "IsDecomposedBy" ) and element .IsDecomposedBy ):
34+ collection = obj .users_collection [0 ]
35+ collection .name = obj .name
3336 element .Name = "/" .join (obj .name .split ("/" )[1 :])
3437 AttributeData .load (IfcStore .get_file (), obj .BIMObjectProperties .ifc_definition_id )
3538
@@ -69,13 +72,13 @@ def purge_module_data():
6972def loadIfcStore (scene ):
7073 IfcStore .file = None
7174 IfcStore .schema = None
72- props = bpy . context . scene . BIMProperties
73- IfcStore .id_map = (
74- { int ( k ): bpy . data . objects . get ( v ) for k , v in json . loads ( props . id_map ). items ()} if props . id_map else {}
75- )
76- IfcStore . guid_map = (
77- { k : bpy . data . objects . get ( v ) for k , v in json . loads ( props . guid_map ). items ()} if props . id_map else {}
78- )
75+ ifc_file = IfcStore . get_file ()
76+ IfcStore .get_schema ()
77+ [
78+ IfcStore . link_element ( ifc_file . by_id ( o . BIMObjectProperties . ifc_definition_id ), o )
79+ for o in bpy . data . objects
80+ if o . BIMObjectProperties . ifc_definition_id
81+ ]
7982 purge_module_data ()
8083
8184
@@ -85,25 +88,6 @@ def ensureIfcExported(scene):
8588 bpy .ops .export_ifc .bim ("INVOKE_DEFAULT" )
8689
8790
88- @persistent
89- def storeIdMap (scene ):
90- try :
91- bpy .context .scene .BIMProperties .id_map = json .dumps ({k : v .name for k , v in IfcStore .id_map .items ()})
92- bpy .context .scene .BIMProperties .guid_map = json .dumps ({k : v .name for k , v in IfcStore .guid_map .items ()})
93- except :
94- # Regenerate maps. Is there a better solution for this? It seems fragile.
95- file = IfcStore .get_file ()
96- IfcStore .id_map = {
97- o .ifc_definition_id : o .name for o in bpy .data .objects if o .BIMObjectProperties .ifc_definition_id
98- }
99- IfcStore .guid_map = {
100- file .by_id (i ).GlobalId : n for i , n in IfcStore .id_map .items () if file .by_id (i ).is_a ("IfcRoot" )
101- }
102- # Then attempt to store it again
103- bpy .context .scene .BIMProperties .id_map = json .dumps ({k : v .name for k , v in IfcStore .id_map .items ()})
104- bpy .context .scene .BIMProperties .guid_map = json .dumps ({k : v .name for k , v in IfcStore .guid_map .items ()})
105-
106-
10791def get_application (ifc ):
10892 version = get_application_version ()
10993 for element in ifc .by_type ("IfcApplication" ):
@@ -176,12 +160,12 @@ def create_application_organisation(ifc):
176160@persistent
177161def setDefaultProperties (scene ):
178162 ifcopenshell .api .owner .settings .get_person = (
179- lambda ifc : ifc .by_id (int (bpy .context .scene .BIMOwnerProperties .user_person ))
163+ lambda ifc : ifc .by_id (int (bpy .context .scene .BIMOwnerProperties .user_person ))
180164 if bpy .context .scene .BIMOwnerProperties .user_person
181165 else None
182166 )
183167 ifcopenshell .api .owner .settings .get_organisation = (
184- lambda ifc : ifc .by_id (int (bpy .context .scene .BIMOwnerProperties .user_organisation ))
168+ lambda ifc : ifc .by_id (int (bpy .context .scene .BIMOwnerProperties .user_organisation ))
185169 if bpy .context .scene .BIMOwnerProperties .user_organisation
186170 else None
187171 )
0 commit comments