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
Dear Alexandros,
Yes, you can determine the hosted elements either before or after copying the hosts.
This is illustrated clearly by the MaterialQuantities Revit SDK sample.
It uses the temporary transaction trick to determine net and gross BIM element material quantities like this:
Look at the SDK sample to see how that can be achieved.
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.