MVD exception
kavehAlahdin opened this issue · 5 comments
With a MVD containing IfcBuilding with concept template 'revision control' , I am getting this exception:
Error:
'NoneType' object has no attribute 'Purpose'
end
<class 'NoneType'>
<class 'NoneType'>
Thanks for reporting. Can you share the mvdXML file? There are quite a bit of versions of the schema floating around. Would help us investigate.
Thanks for the reply!
I saved it in ifcdoc in mvdxml version 1.1(the official version)
Using different Ifc files I get similar exceptions for different attributes.
IfcBuilding.txt
This file is actually a mvdxml file. I changed it to txt, so I can upload it.
With the recent commits you can get the expected results using the snippet below on the model here in IFC4 at http://openifcmodel.cs.auckland.ac.nz/Model/Details/307 :
import ifcopenshell
from ifcopenshell.mvd import mvd
concept_roots = list(ifcopenshell.mvd.concept_root.parse(r"examples/building.mvdxml"))
file = ifcopenshell.open(r"models\20160125Autodesk_Hospital_Parking Garage_2015 - IFC4.ifc")
for concept_root in concept_roots:
print("ConceptRoot: ", concept_root.entity)
example_entity = file.by_type(concept_root.entity)[0]
concepts = sorted(concept_root.concepts(), key=mvd.is_applicability, reverse=True)
for concept in concepts:
print("Concept Name: ", concept.name)
# print(concept.template().rules)
if len(concept.template().rules) > 1:
attribute_rules = []
for rule in concept.template().rules:
attribute_rules.append(rule)
rules_root = ifcopenshell.mvd.rule("EntityRule", concept_root.entity, attribute_rules)
else:
rules_root = concept.template().rules[0]
data = mvd.extract_data(rules_root, example_entity)
print("Result from traversal:")
for d in data:
for k,v in d.items():
print(k,v)
print()
print("\n")
Output:
ConceptRoot: IfcBuilding
Concept Name: Spatial Decomposition
Result from traversal:
<Rule EntityRule IfcLabel> Potential Ground Water Elevation
<Rule EntityRule IfcLabel> Ground Floor
<Rule EntityRule IfcLabel> Exist Garage - Ground Level
<Rule EntityRule IfcLabel> 1st Floor
<Rule EntityRule IfcLabel> Existing Garage - 1st Level
<Rule EntityRule IfcLabel> Existing Garage - 2nd Level
<Rule EntityRule IfcLabel> 2nd Floor
<Rule EntityRule IfcLabel> Existing Garage - 3rd Level
<Rule EntityRule IfcLabel> Existing Garage - 4th Level
<Rule EntityRule IfcLabel> Existing Garage - 5th Level
<Rule EntityRule IfcLabel> Existing Garage - Roof Level
<Rule EntityRule IfcLabel> Exhaust Structure Roof
Concept Name: Spatial Composition
Result from traversal:
<Rule EntityRule IfcLabel> Default
Concept Name: Classification Association
Result from traversal:
<Rule AttributeRule HasAssociations> empty data structure
Concept Name: Object Typing
Result from traversal:
<Rule AttributeRule IsTypedBy> empty data structure
Concept Name: Property Sets for Objects
Result from traversal:
<Rule AttributeRule PredefinedType> Invalid Attribute
<Rule EntityRule IfcLabel> Pset_BuildingCommon
<Rule EntityRule IfcIdentifier> Reference
<Rule AttributeRule Description> Nonexistent value
<Rule EntityRule IfcValue> IfcIdentifier('Project Information')
<Rule AttributeRule Purpose> Invalid attribute rule
<Rule AttributeRule PredefinedType> Invalid Attribute
<Rule EntityRule IfcLabel> Pset_BuildingCommon
<Rule EntityRule IfcIdentifier> NumberOfStoreys
<Rule AttributeRule Description> Nonexistent value
<Rule EntityRule IfcValue> IfcInteger(12)
<Rule AttributeRule Purpose> Invalid attribute rule
Concept Name: Quantity Sets
Result from traversal:
Concept Name: Product Local Placement
Result from traversal:
<Rule EntityRule IfcAxis2Placement3D> #32=IfcAxis2Placement3D(#6,$,$)
<Rule EntityRule IfcLocalPlacement> #196109=IfcLocalPlacement($,#196108)
Concept Name: Box Geometry
Result from traversal:
<Rule AttributeRule Representation> Nonexistent value
Concept Name: Spatial Container
Result from traversal:
<Rule AttributeRule ContainsElements> empty data structure
Concept Name: Building Attributes
Result from traversal:
<Rule EntityRule IfcLabel>
<Rule EntityRule IfcLabel>
<Rule EntityRule IfcElementCompositionEnum> ELEMENT
<Rule AttributeRule ElevationOfRefHeight> Nonexistent value
<Rule AttributeRule ElevationOfTerrain> Nonexistent value
<Rule AttributeRule Purpose> Nonexistent value
<Rule AttributeRule Description> Nonexistent value
<Rule AttributeRule UserDefinedPurpose> Nonexistent value
<Rule AttributeRule InternalLocation> Nonexistent value
<Rule EntityRule IfcLabel> Enter address here
<Rule AttributeRule PostalBox> Nonexistent value
<Rule EntityRule IfcLabel>
<Rule EntityRule IfcLabel> Rochester
<Rule EntityRule IfcLabel>
<Rule EntityRule IfcLabel> NY
Concept Name: Object Predefined Type
Result from traversal:
<Rule AttributeRule ObjectType> Nonexistent value
<Rule AttributeRule IsTypedBy> empty data structure
Concept Name: Object User Identity
Result from traversal:
<Rule EntityRule IfcLabel>
<Rule AttributeRule Description> Nonexistent value
<Rule AttributeRule IsTypedBy> empty data structure
Thanks alot Johan. It is working. I can produce the same result as you have.
I have a confusion still. How can I use mvd to create the result ifc file? I see the data
variable from above being a list of concepts and using extract_data
and there is also the example from readme
file with get_data() method.
I am not sure how I can follow up!
Thanks
Kaveh