mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 05:00:53 +00:00
Optimise import to only consider surface styles
This commit is contained in:
@@ -85,8 +85,11 @@ class MaterialCreator:
|
|||||||
item_id = self.mesh.BIMMeshProperties.ifc_item_ids.add()
|
item_id = self.mesh.BIMMeshProperties.ifc_item_ids.add()
|
||||||
item_id.name = str(item.id())
|
item_id.name = str(item.id())
|
||||||
|
|
||||||
styled_item = item.StyledByItem[0]
|
styled_item = item.StyledByItem[0] # Cardinality is S[0:1]
|
||||||
style_name = self.get_style_name(styled_item)
|
style_name = self.get_surface_style_name(styled_item)
|
||||||
|
|
||||||
|
if not style_name:
|
||||||
|
return
|
||||||
|
|
||||||
if self.mesh.materials.get(style_name):
|
if self.mesh.materials.get(style_name):
|
||||||
item_id.slot_index = self.mesh.materials.find(style_name)
|
item_id.slot_index = self.mesh.materials.find(style_name)
|
||||||
@@ -266,7 +269,7 @@ class MaterialCreator:
|
|||||||
continue
|
continue
|
||||||
self.parse_styled_item(item, obj)
|
self.parse_styled_item(item, obj)
|
||||||
|
|
||||||
def get_style_name(self, styled_item):
|
def get_surface_style_name(self, styled_item):
|
||||||
if styled_item.Name:
|
if styled_item.Name:
|
||||||
return styled_item.Name
|
return styled_item.Name
|
||||||
styles = self.get_styled_item_styles(styled_item)
|
styles = self.get_styled_item_styles(styled_item)
|
||||||
@@ -276,7 +279,7 @@ class MaterialCreator:
|
|||||||
if style.Name:
|
if style.Name:
|
||||||
return style.Name
|
return style.Name
|
||||||
return str(style.id())
|
return str(style.id())
|
||||||
return str(styled_item.id())
|
return None # We only support surface styles right now
|
||||||
|
|
||||||
def parse_styled_item(self, styled_item, material):
|
def parse_styled_item(self, styled_item, material):
|
||||||
styles = self.get_styled_item_styles(styled_item)
|
styles = self.get_styled_item_styles(styled_item)
|
||||||
@@ -1098,7 +1101,7 @@ class IfcImporter:
|
|||||||
if not item.StyledByItem:
|
if not item.StyledByItem:
|
||||||
return
|
return
|
||||||
styled_item = item.StyledByItem[0]
|
styled_item = item.StyledByItem[0]
|
||||||
return self.material_creator.get_style_name(styled_item)
|
return self.material_creator.get_surface_style_name(styled_item)
|
||||||
|
|
||||||
def transform_curve(self, curve, matrix):
|
def transform_curve(self, curve, matrix):
|
||||||
for spline in curve.splines:
|
for spline in curve.splines:
|
||||||
|
|||||||
Reference in New Issue
Block a user