mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 13:04:49 +00:00
import elements with no material or profile
This commit is contained in:
+28
-13
@@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
import json
|
import json
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -17,7 +19,7 @@ class IFC2CA:
|
|||||||
|
|
||||||
materialdb = []
|
materialdb = []
|
||||||
materials = list(dict.fromkeys([e['material'] for e in elements]))
|
materials = list(dict.fromkeys([e['material'] for e in elements]))
|
||||||
for mat in materials:
|
for mat in [mat for mat in materials if mat]:
|
||||||
id = int(mat.split('|')[1])
|
id = int(mat.split('|')[1])
|
||||||
material = self.get_material_properties(self.file.by_id(id))
|
material = self.get_material_properties(self.file.by_id(id))
|
||||||
material['relatedElements'] = [e['ifcName'] for e in elements if 'material' in e and e['material'] == mat]
|
material['relatedElements'] = [e['ifcName'] for e in elements if 'material' in e and e['material'] == mat]
|
||||||
@@ -25,7 +27,7 @@ class IFC2CA:
|
|||||||
|
|
||||||
profiledb = []
|
profiledb = []
|
||||||
profiles = list(dict.fromkeys([e['profile'] for e in elements if 'profile' in e]))
|
profiles = list(dict.fromkeys([e['profile'] for e in elements if 'profile' in e]))
|
||||||
for prof in profiles:
|
for prof in [prof for prof in profiles if prof]:
|
||||||
id = int(prof.split('|')[1])
|
id = int(prof.split('|')[1])
|
||||||
profile = self.get_profile_properties(self.file.by_id(id))
|
profile = self.get_profile_properties(self.file.by_id(id))
|
||||||
profile['relatedElements'] = [e['ifcName'] for e in elements if 'profile' in e and e['profile'] == prof]
|
profile['relatedElements'] = [e['ifcName'] for e in elements if 'profile' in e and e['profile'] == prof]
|
||||||
@@ -44,7 +46,7 @@ class IFC2CA:
|
|||||||
'warnings': self.warnings
|
'warnings': self.warnings
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Model %s converted' % model.Name)
|
print('Model "%s" converted' % model.Name)
|
||||||
print('Number of elements: ', len(elements))
|
print('Number of elements: ', len(elements))
|
||||||
print('Number of connections: ', len(connections))
|
print('Number of connections: ', len(connections))
|
||||||
print('Number of materials: ', len(materialdb))
|
print('Number of materials: ', len(materialdb))
|
||||||
@@ -70,12 +72,19 @@ class IFC2CA:
|
|||||||
if item.is_a('IfcStructuralCurveMember'):
|
if item.is_a('IfcStructuralCurveMember'):
|
||||||
representation = self.get_representation(item, 'Edge')
|
representation = self.get_representation(item, 'Edge')
|
||||||
material_profile = self.get_material_profile(item)
|
material_profile = self.get_material_profile(item)
|
||||||
if not representation or not material_profile:
|
if not representation:
|
||||||
print(representation, material_profile)
|
# add to warnings
|
||||||
return
|
return
|
||||||
|
if not material_profile:
|
||||||
|
#add to warnings
|
||||||
|
materialId = None
|
||||||
|
profileId = None
|
||||||
|
else:
|
||||||
|
material = material_profile.Material
|
||||||
|
materialId = material.is_a() + '|' + str(material.id())
|
||||||
|
profile = material_profile.Profile
|
||||||
|
profileId = profile.is_a() + '|' + str(profile.id())
|
||||||
|
|
||||||
material = material_profile.Material
|
|
||||||
profile = material_profile.Profile
|
|
||||||
geometry = self.get_geometry(representation)
|
geometry = self.get_geometry(representation)
|
||||||
orientation = self.get_1D_orientation(geometry, item.Axis)
|
orientation = self.get_1D_orientation(geometry, item.Axis)
|
||||||
connections = self.get_connection_data(item.ConnectedBy)
|
connections = self.get_connection_data(item.ConnectedBy)
|
||||||
@@ -107,8 +116,8 @@ class IFC2CA:
|
|||||||
'predefinedType': item.PredefinedType,
|
'predefinedType': item.PredefinedType,
|
||||||
'geometry': geometry,
|
'geometry': geometry,
|
||||||
'orientation': orientation,
|
'orientation': orientation,
|
||||||
'material': material.is_a() + '|' + str(material.id()),
|
'material': materialId,
|
||||||
'profile': profile.is_a() + '|' + str(profile.id()),
|
'profile': profileId,
|
||||||
'connections': connections
|
'connections': connections
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +125,13 @@ class IFC2CA:
|
|||||||
representation = self.get_representation(item, 'Face')
|
representation = self.get_representation(item, 'Face')
|
||||||
material = self.get_material_profile(item)
|
material = self.get_material_profile(item)
|
||||||
if not representation:
|
if not representation:
|
||||||
print(representation)
|
# add to warnings
|
||||||
return
|
return
|
||||||
|
if not material:
|
||||||
|
#add to warnings
|
||||||
|
materialId = None
|
||||||
|
else:
|
||||||
|
materialId = material.is_a() + '|' + str(material.id())
|
||||||
|
|
||||||
geometry = self.get_geometry(representation)
|
geometry = self.get_geometry(representation)
|
||||||
orientation = self.get_2D_orientation(representation)
|
orientation = self.get_2D_orientation(representation)
|
||||||
@@ -140,14 +154,14 @@ class IFC2CA:
|
|||||||
'thickness': item.Thickness,
|
'thickness': item.Thickness,
|
||||||
'geometry': geometry,
|
'geometry': geometry,
|
||||||
'orientation': orientation,
|
'orientation': orientation,
|
||||||
'material': material.is_a() + '|' + str(material.id()),
|
'material': materialId,
|
||||||
'connections': connections
|
'connections': connections
|
||||||
}
|
}
|
||||||
|
|
||||||
elif item.is_a('IfcStructuralPointConnection'):
|
elif item.is_a('IfcStructuralPointConnection'):
|
||||||
representation = self.get_representation(item, 'Vertex')
|
representation = self.get_representation(item, 'Vertex')
|
||||||
if not representation:
|
if not representation:
|
||||||
print(representation)
|
# add to warnings
|
||||||
return
|
return
|
||||||
|
|
||||||
geometry = self.get_geometry(representation)
|
geometry = self.get_geometry(representation)
|
||||||
@@ -219,7 +233,7 @@ class IFC2CA:
|
|||||||
return rep
|
return rep
|
||||||
|
|
||||||
def get_specific_representation(self, representation, rep_id, rep_type):
|
def get_specific_representation(self, representation, rep_id, rep_type):
|
||||||
if representation.RepresentationIdentifier == rep_id \
|
if representation.RepresentationIdentifier == rep_id or rep_id is None \
|
||||||
and representation.RepresentationType == rep_type:
|
and representation.RepresentationType == rep_type:
|
||||||
return representation
|
return representation
|
||||||
if representation.RepresentationType == 'MappedRepresentation':
|
if representation.RepresentationType == 'MappedRepresentation':
|
||||||
@@ -334,6 +348,7 @@ class IFC2CA:
|
|||||||
return {
|
return {
|
||||||
'ifcName': material.is_a() + '|' + str(material.id()),
|
'ifcName': material.is_a() + '|' + str(material.id()),
|
||||||
'name': material.Name,
|
'name': material.Name,
|
||||||
|
'category': material.Category,
|
||||||
'mechProps': mechProps,
|
'mechProps': mechProps,
|
||||||
'commonProps':commonProps
|
'commonProps':commonProps
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user