I want to convert an IFC file to a graph database to extract adjacency and accessibility of the spaces in the IFC model. I wanted to use Neo4j, and as a part of this job, I need to extract a Cypher code from the IFC file. I found this code but when I run it, I encounter the error below:
AttributeError Traceback (most recent call last)
<ipython-input-1-b13704b3ee10> in <module>
20 typeDict = IfcTypeDict()
21
---> 22 assert typeDict['IfcWall'] == ('GlobalId', 'OwnerHistory', 'Name', 'Description', 'ObjectType', 'ObjectPlacement', 'Representation', 'Tag')
23
24 nodes = []
<ipython-input-1-b13704b3ee10> in __missing__(self, key)
15 class IfcTypeDict(dict):
16 def __missing__(self, key):
---> 17 value = self[key] = ifcopenshell.create_entity(key).wrapped_data.get_attribute_names()
18 return value
19
AttributeError: 'str' object has no attribute 'get_attribute_names'
Can anyone help me with this? or any other idea about how I can perform this task? any help would be greatly appreciated.
Regards.
It seems this script was created for IfcOpenShell v0.5 compiled for IFC2x3 while you are using IfcOpenShell v0.6, which is unfortunately not backwards-compatible. You could either try to use v0.5 or update the script to the v0.6 API.
If you use v0.5, be aware that this version was compiled for a specific IFC version. I believe the published packages are for IFC2x3, thus it will not work with IFC4 files. You could compile for IFC4 though, but then would loose IFC2x3 support. The assertion wouldn't work anymore, because IFC4 walls have one more attribute PredefinedType
:
assert typeDict["IfcWall"] == ('GlobalId', 'OwnerHistory', 'Name', 'Description', 'ObjectType', 'ObjectPlacement', 'Representation', 'Tag', 'PredefinedType')
Alternatively if using v0.6 you will have to change more in the script. Maybe like in this updated Gist. There was another issue further down and you might encounter more. If in doubt, try to contact the original author or use the script as an inspiration to write your own conversion.