Copy Element
- Last UpdatedJun 02, 2022
- 1 minute read
As with Delete, the standard COPY method copies the primary hierarchy. The following points are relevant when copying:
-
Certain attributes are not copied, for example: NAME.
-
For Name attributes, automatic renaming is possible
-
The element may be copied to an existing element, or as a new element.
-
Cross references within the copied hierarchy are automatically updated to the copied element. References external to the copied hierarchy are left unchanged.
There are further details in the reference manuals.
An example of the DbElement method is:
myEle1.Copy(myEle2);
myEle1.CreateCopyHierarchyAfter(myEle2,copyoption);
The first example copies 'myEle2' on top of myEle1. The second example copies myEle2 and all its descendants to a new element after myEle1.
There are methods to:
-
Copy a single element to an existing element
-
Copy an element and all its descendants to an existing element
-
Copy an element and all its descendants to a new element
-
Copy common attributes ('CopyLike') between existing elements
There is a separate class DbCopyOption to hold the options when doing a copy. These options are only available when copying an element and all its descendants.
The element types must match if copying to an existing element.
There is a boolean method IsCopyable to test if an element can be copied.