PDA

View Full Version : 2012 Pass Elemnt from Document to another Revit Api c#



halagamal2009419923
2013-09-17, 03:09 PM
Hey,I'm trying to make copy from family Document contain Extrusion (the Element i want to select ) and make copy of it in another Document "I mean there is two opened Documents where i select the element from the family file and paste it in another project file ".
My Code Sequence:
1.Make User selects the Element.
2.get Element ID and get its location
3.Make the user select the palce where he wants to make a copy of the element "it may be another Document" so before this ,I get the Active Document .
4.copy command by elemnt id and new position enetered by user.
The Problem is :
the active document command raises an exception with selection command and Now i don't know how to solve this issue?
, also is it will be IExternalApplication or IExternalCommand?
and why when i load family in my document ,the family not appears?
Please Help me .
Thanks In Advance :)

Maxence DELANNOY
2013-09-18, 05:52 AM
Which version of Revit? What is exacty the exception? Please provide us more details and don't ask several questions on a single thread.

halagamal2009419923
2013-09-19, 02:10 AM
first i'm sorry for asking several questions in the same thread but i'm new to Revit Programming so i need some guidness. I use Revit Arch 2012.
The Exception from pickObj because using of " _doc = commandData.Application.ActiveUIDocument.Document;" when press in another revit document.
Can you Help me please?

Maxence DELANNOY
2013-09-19, 05:39 AM
I don't believe that you can do this on 2012. The API for transferring elements from one document to an other has been introduced in 2014: http://thebuildingcoder.typepad.com/blog/2013/05/copy-and-paste-api-applications-and-modeless-assertion.html. What you can do is perhaps creating a new element and copy the values of the source parameters. See also: http://adndevblog.typepad.com/aec/2013/05/copy-family-between-documents-via-api.html