Use CopyElements ignoring their hosted elements
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Problem:
I have used the CopyElements method which causes a "Autodesk.Revit.Exceptions.InvalidOperationException: Copying one or more elements failed." exception. When I manually try to copy the elements from the Revit UI I receive the message "Can't copy to clipboard because of relationship between Elements" which I believe is related to the Revit API InvalidOperationException above.
To avoid the above problem I discovered that if I copy the elements one by one Revit ignores the relationships between the element and allows elements to be copied. Therefore I don't receive the above Exception from the Revit API. When elements using the CopyElements method which are hosts, Revit also copies automatically all hosted elements associated with their hosts. The problem is that CopyElements method does not return any of the hosted Elements and this makes the Copy operation very difficult to control.
Questions:
1. Is there any way to overcome the InvalidOperationException associated with the "Selection cannot be copied. Cannot copy to clipboard because of relationship between elements." when copying multiple elements together?
2. Is there any easy way to find the newly added hosted elements when copying hosts using the CopyElements method?
Many thanks,
Alexandros