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
)
| 1722 | |
| 1723 | |
| 1724 | def 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 | |
| 1749 | def copy_deep( |
no test coverage detected