MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / copy

Function copy

src/ifcopenshell-python/ifcopenshell/util/element.py:1724–1746  ·  view source on GitHub ↗

Copy a single element. Any referenced elements are not copied. GlobalIds are regenerated. :param ifc_file: The IFC file object :param element: The IFC element to copy :return: The newly copied element

(
    ifc_file: Union[ifcopenshell.file, None], element: ifcopenshell.entity_instance
)

Source from the content-addressed store, hash-verified

1722
1723
1724def copy(
1725 ifc_file: Union[ifcopenshell.file, None], element: ifcopenshell.entity_instance
1726) -> ifcopenshell.entity_instance:
1727 """
1728 Copy a single element. Any referenced elements are not copied.
1729
1730 GlobalIds are regenerated.
1731
1732 :param ifc_file: The IFC file object
1733 :param element: The IFC element to copy
1734 :return: The newly copied element
1735 """
1736 if not ifc_file:
1737 ifc_file = element.file
1738 new = ifc_file.create_entity(element.is_a())
1739 for i, attribute in enumerate(element):
1740 if attribute is None:
1741 continue
1742 if new.attribute_name(i) == "GlobalId":
1743 new[i] = ifcopenshell.guid.new()
1744 else:
1745 new[i] = attribute
1746 return new
1747
1748
1749def copy_deep(

Callers 8

writeMethod · 0.85
writeNodeMethod · 0.85
compute_boundsMethod · 0.85
IfcGlobalIdMethod · 0.85
all_attributesFunction · 0.85
all_inverse_attributesFunction · 0.85
splitFunction · 0.85

Calls 4

attribute_nameMethod · 0.80
newMethod · 0.80
create_entityMethod · 0.45
is_aMethod · 0.45

Tested by

no test coverage detected