mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
project.append_asset - slight optimization for existing elements search
This commit is contained in:
@@ -172,14 +172,18 @@ class Usecase:
|
|||||||
def get_existing_element(self, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
def get_existing_element(self, element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity_instance, None]:
|
||||||
if element.id() in self.added_elements:
|
if element.id() in self.added_elements:
|
||||||
return self.added_elements[element.id()]
|
return self.added_elements[element.id()]
|
||||||
try:
|
if element.is_a("IfcRoot"):
|
||||||
if element.is_a("IfcRoot"):
|
try:
|
||||||
return self.file.by_guid(element.GlobalId)
|
return self.file.by_guid(element.GlobalId)
|
||||||
elif element.is_a("IfcMaterial"):
|
except RuntimeError:
|
||||||
return [e for e in self.file.by_type("IfcMaterial") if e.Name == element.Name][0]
|
return None
|
||||||
elif element.is_a("IfcProfileDef"):
|
elif element.is_a("IfcMaterial"):
|
||||||
return [e for e in self.file.by_type("IfcProfileDef") if e.ProfileName == element.ProfileName][0]
|
material_name = element.Name
|
||||||
except:
|
return next((e for e in self.file.by_type("IfcMaterial") if e.Name == material_name), None)
|
||||||
|
elif element.is_a("IfcProfileDef"):
|
||||||
|
profile_name = element.ProfileName
|
||||||
|
return next((e for e in self.file.by_type("IfcProfileDef") if e.ProfileName == profile_name), None)
|
||||||
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def append_material(self):
|
def append_material(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user