mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-07 12:56:26 +00:00
fix errors linking ifc2x3 projects
it was failing with something very verbose:
```
File "\blenderbim\bim\module\project\operator.py", line 1239, in execute
db = ifcpatch.execute(
^^^^^^^^^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcpatch\__init__.py", line 80, in execute
patcher.patch()
File "\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractPropertiesToSQLite.py", line 137, in patch
properties.append([i, "IFC Material", f"Layer {idx + 1} Name", item.Name])
^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 197, in __getattr__
raise AttributeError(
AttributeError: entity instance of type 'IFC2X3.IfcMaterialLayer' has no attribute 'Name'
Error: Python: Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 1239, in execute
db = ifcpatch.execute(
^^^^^^^^^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcpatch\__init__.py", line 80, in execute
patcher.patch()
File "\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractPropertiesToSQLite.py", line 137, in patch
properties.append([i, "IFC Material", f"Layer {idx + 1} Name", item.Name])
^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 197, in __getattr__
raise AttributeError(
AttributeError: entity inTraceback (most recent call last):
File "\Temp\tmpdggt3syt.py", line 9, in <module>
run()
File "\Temp\tmpdggt3syt.py", line 5, in run
bpy.ops.bim.load_linked_project(filepath="/Dormitory-ARC.ifc", false_origin="0,0,0")
File "\Blender\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
ret = _op_call(self.idname_py(), kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Python: Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 1239, in execute
db = ifcpatch.execute(
^^^^^^^^^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcpatch\__init__.py", line 80, in execute
patcher.patch()
File "\blenderbim\libs\site\packages\ifcpatch\recipes\ExtractPropertiesToSQLite.py", line 137, in patch
properties.append([i, "IFC Material", f"Layer {idx + 1} Name", item.Name])
^^^^^^^^^
File "\blenderbim\libs\site\packages\ifcopenshell\entity_instance.py", line 197, in __getattr__
raise AttributeError(
AttributeError: entity instance of type 'IFC2X3.IfcMaterialLayer' has no attribute 'Name'
Location: \Blender\4.1\scripts\modules\bpy\ops.py:109
... truncatedUnregistered Snippets Library
BMAX Connector - UnRegistred!
An error occurred while processing your IFC.
Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 949, in execute
self.link_ifc()
File "\blenderbim\bim\module\project\operator.py", line 991, in link_ifc
self.link_blend(blend_filepath)
File "\blenderbim\bim\module\project\operator.py", line 953, in link_blend
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
OSError: load: \Dormitory-ARC.ifc.cache.blend failed to open blend file
Error: Python: Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 949, in execute
self.link_ifc()
File "\blenderbim\bim\module\project\operator.py", line 991, in link_ifc
self.link_blend(blend_filepath)
File "\blenderbim\bim\module\project\operator.py", line 953, in link_blend
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
OSError: load: \Dormitory-ARC.ifc.cache.blend failed to open blend file
Location: \Blender\4.1\scripts\modules\bpy\ops.py:109
Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 870, in execute
bpy.ops.bim.load_link(filepath=filepath, false_origin=self.false_origin)
File "\Blender\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
ret = _op_call(self.idname_py(), kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Python: Traceback (most recent call last):
File "\blenderbim\bim\module\project\operator.py", line 949, in execute
self.link_ifc()
File "\blenderbim\bim\module\project\operator.py", line 991, in link_ifc
self.link_blend(blend_filepath)
File "\blenderbim\bim\module\project\operator.py", line 953, in link_blend
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
OSError: load: \Dormitory-ARC.ifc.cache.blend failed to open blend file
Location: \Blender\4.1\scripts\modules\bpy\ops.py:109
```
This commit is contained in:
@@ -23,6 +23,7 @@ import json
|
|||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite3
|
import sqlite3
|
||||||
@@ -106,14 +107,16 @@ class Patcher:
|
|||||||
relationships = []
|
relationships = []
|
||||||
id_map = {e.id(): i for i, e in enumerate(elements)}
|
id_map = {e.id(): i for i, e in enumerate(elements)}
|
||||||
for i, element in enumerate(elements):
|
for i, element in enumerate(elements):
|
||||||
rows.append([
|
rows.append(
|
||||||
i,
|
[
|
||||||
element[0],
|
i,
|
||||||
element.is_a(),
|
element[0], # IfcRoot.GlobalId
|
||||||
ifcopenshell.util.element.get_predefined_type(element),
|
element.is_a(),
|
||||||
element[2],
|
ifcopenshell.util.element.get_predefined_type(element),
|
||||||
element[3],
|
element[2], # IfcRoot.Name
|
||||||
])
|
element[3], # IfcRoot.Description
|
||||||
|
]
|
||||||
|
)
|
||||||
psets = ifcopenshell.util.element.get_psets(element, should_inherit=False)
|
psets = ifcopenshell.util.element.get_psets(element, should_inherit=False)
|
||||||
for pset_name, pset_data in psets.items():
|
for pset_name, pset_data in psets.items():
|
||||||
for prop_name, value in pset_data.items():
|
for prop_name, value in pset_data.items():
|
||||||
@@ -134,27 +137,30 @@ class Patcher:
|
|||||||
materials = []
|
materials = []
|
||||||
elif material.is_a("IfcMaterialLayerSet"):
|
elif material.is_a("IfcMaterialLayerSet"):
|
||||||
for idx, item in enumerate(material.MaterialLayers):
|
for idx, item in enumerate(material.MaterialLayers):
|
||||||
properties.append([i, "IFC Material", f"Layer {idx + 1} Name", item.Name])
|
material = item.Material
|
||||||
properties.append([i, "IFC Material", f"Layer {idx + 1} Material", item.Material.Name])
|
properties.append([i, "IFC Material", f"Layer {idx + 1} Name", getattr(item, "Name", None)])
|
||||||
if getattr(item.Material, "Category"):
|
properties.append([i, "IFC Material", f"Layer {idx + 1} Material", material.Name])
|
||||||
properties.append([i, "IFC Material", f"Layer {idx + 1} Category", item.Material.Category])
|
if category := getattr(material, "Category", None):
|
||||||
|
properties.append([i, "IFC Material", f"Layer {idx + 1} Category", category])
|
||||||
elif material.is_a("IfcMaterialProfileSet"):
|
elif material.is_a("IfcMaterialProfileSet"):
|
||||||
for idx, item in enumerate(material.MaterialProfiles):
|
for idx, item in enumerate(material.MaterialProfiles):
|
||||||
|
material = item.Material
|
||||||
properties.append([i, "IFC Material", f"Profile {idx + 1} Name", item.Name])
|
properties.append([i, "IFC Material", f"Profile {idx + 1} Name", item.Name])
|
||||||
properties.append([i, "IFC Material", f"Profile {idx + 1} Material", item.Material.Name])
|
properties.append([i, "IFC Material", f"Profile {idx + 1} Material", material.Name])
|
||||||
if getattr(item.Material, "Category"):
|
if category := getattr(material, "Category", None):
|
||||||
properties.append([i, "IFC Material", f"Profile {idx + 1} Category", item.Material.Category])
|
properties.append([i, "IFC Material", f"Profile {idx + 1} Category", category])
|
||||||
elif material.is_a("IfcMaterialConstituentSet"):
|
elif material.is_a("IfcMaterialConstituentSet"):
|
||||||
for idx, item in enumerate(material.MaterialConstituents):
|
for idx, item in enumerate(material.MaterialConstituents):
|
||||||
|
material = item.Material
|
||||||
properties.append([i, "IFC Material", f"Constituent {idx + 1} Name", item.Name])
|
properties.append([i, "IFC Material", f"Constituent {idx + 1} Name", item.Name])
|
||||||
properties.append([i, "IFC Material", f"Constituent {idx + 1} Material", item.Material.Name])
|
properties.append([i, "IFC Material", f"Constituent {idx + 1} Material", material.Name])
|
||||||
if getattr(item.Material, "Category"):
|
if category := getattr(material, "Category", None):
|
||||||
properties.append([i, "IFC Material", f"Constituent {idx + 1} Category", item.Material.Category])
|
properties.append([i, "IFC Material", f"Constituent {idx + 1} Category", category])
|
||||||
elif material.is_a("IfcMaterialList"):
|
elif material.is_a("IfcMaterialList"):
|
||||||
for idx, material in enumerate(material.Materials):
|
for idx, material in enumerate(material.Materials):
|
||||||
properties.append([i, "IFC Material", f"Material {idx + 1} Name", material.Name])
|
properties.append([i, "IFC Material", f"Material {idx + 1} Name", material.Name])
|
||||||
if getattr(material, "Category"):
|
if category := getattr(material, "Category", None):
|
||||||
properties.append([i, "IFC Material", f"Material {idx + 1} Category", material.Category])
|
properties.append([i, "IFC Material", f"Material {idx + 1} Category", category])
|
||||||
|
|
||||||
layers = ifcopenshell.util.element.get_layers(self.file, element)
|
layers = ifcopenshell.util.element.get_layers(self.file, element)
|
||||||
for idx, layer in enumerate(layers):
|
for idx, layer in enumerate(layers):
|
||||||
|
|||||||
Reference in New Issue
Block a user