How to copy element from view to another view ??

How to copy element from view to another view ??

Anonymous
Not applicable
4,555 Views
7 Replies
Message 1 of 8

How to copy element from view to another view ??

Anonymous
Not applicable

I use method ElementTransformUtils.CopyElements Method (View, ICollection(ElementId), View, Transform, CopyPasteOptions) to copy some 2D element from one view to another. it's error like picture below "document expected.." Maybe it don't understand my method, we have another method to copy element from document to another document : ElementTransformUtils.CopyElements Method (Document, ICollection(ElementId), Document, Transform, CopyPasteOptions). But i just only want to copy element from view to view, don't want to copy from document to document. Anyone has idea ?? Thanks.UntitledCapture

0 Likes
Accepted solutions (2)
4,556 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
still need a solution. Thanks
0 Likes
Message 3 of 8

stever66
Advisor
Advisor
Accepted solution

From the SDK Revit API.chm, copyelements needs an Icollection of elements ID's (Icollection<ElementIds>).

 

Revit has mutliple ways to refer to an element.  You can refer directly to the element, you can get a reference to the element, or you can get the ElementId.

 

In this case, I beleive you need to get the elementid, and put it in a collection of Element Id's.

 

Here is the best example I can find offhand, but its in C#, and is doing something different.   But it does have a collection of element ID's:

 

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-...


To convert to python, you have to omit the ; at the end of each line, and when you declare a variable, you don't declare the type.

 

I suggest starting with the simplest example possible and building on it until you get what you want.

Message 4 of 8

Anonymous
Not applicable
In addition to the List of Element Ids that Stever66 pointed out, that CopyElements overload takes 4 inputs. It takes a Transform which I believe you can set as null if its just copy/pasting to the same place.
Message 5 of 8

Anonymous
Not applicable
Sorry it takes 5 inputs. It needs a CopyPasteOptions as well. I've tried replicating your code but it appears to be defaulting to the first overload and not the one we are trying to use.
Message 6 of 8

stever66
Advisor
Advisor
Accepted solution

I saw the 5 inputs also, but I wasn't sure if they were all required.

 

i wasn't sure what unwrapping was, so I found this:

 

https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration

 

Anyhow, it made me realize that you also don't have a transaction in your code.  Most Dynamo blocks handle their own transactions, but I believe you still have to include your own transactions for Python blocks.

 

does Dynamo have any custom copy nodes?  If so, maybe you could look at the code behind that block to see how it works. 

Message 7 of 8

Anonymous
Not applicable

I'm sure it's not about transaction, you can see the error, it's can understand method i using "document espected.." while i use the method copy element from view to view not document to document.

still need a solution for this. Thanks all

0 Likes
Message 8 of 8

Anonymous
Not applicable

Yes. that method need 5 arguments, but in fact we can input 3 arguments, the CopyPassOption and Transfrom arguments can set null for them.

Thank you !!

0 Likes