ifcopenshell-Python中没有属性
我正面临这个麻烦 就像这张照片,我不知道如何纠正它 我的代码在这里:ifcopenshell-Python中没有属性,python,ifc,Python,Ifc,我正面临这个麻烦 就像这张照片,我不知道如何纠正它 我的代码在这里: import ifcopenshell ifc_file = ifcopenshell.open(r'C:\Users\18640\Desktop\IFC+RVT\total model\小别墅.ifc') product = ifc_file.by_type('IfcWall')[0] for definition in product.IsDefinedBy: property_definition = def
import ifcopenshell
ifc_file = ifcopenshell.open(r'C:\Users\18640\Desktop\IFC+RVT\total model\小别墅.ifc')
product = ifc_file.by_type('IfcWall')[0]
for definition in product.IsDefinedBy:
property_definition = definition.RelatingPropertyDefinition
print(property_definition.Name)
for property in property_definition.HasProperties:
if property.is_a('IfcPropertySingleValue'):
print(property.Name)
print(property.NominalValue.wrappedValue)
结果:
Traceback (most recent call last):
File "C:/Users/18640/Desktop/ifcopenshell/sample.py", line 6, in <module>
property_definition = definition.RelatingPropertyDefinition
File "C:\ProgramData\Anaconda3\lib\site-packages\ifcopenshell\entity_instance.py", line 68, in __getattr__
"entity instance of type '%s' has no attribute '%s'" % (self.wrapped_data.is_a(), name))
AttributeError: entity instance of type 'IfcRelDefinesByType' has no attribute 'RelatingPropertyDefinition'
回溯(最近一次呼叫最后一次):
文件“C:/Users/18640/Desktop/ifcopenshell/sample.py”,第6行,在
property_definition=definition.RelatingPropertyDefinition
文件“C:\ProgramData\Anaconda3\lib\site packages\ifcopenshell\entity\u instance.py”,第68行,在\uuu getattr中__
类型“%s”的实体实例没有属性“%s”(.self.wrapped_data.is_a(),name))
AttributeError:类型为“IfcRelDefinesByType”的实体实例没有属性“RelatingPropertyDefinition”
好的,我知道了。因为我的iFC版本是2.3,我保存为iFC 4,没关系。如果它不是问题的话,你可以考虑删除这个问题。