Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copying elements, types and parameters

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
franjavigarciavalencia
2645 Views, 3 Replies

Copying elements, types and parameters

franjavigarciavalencia
Enthusiast
Enthusiast

Hello

 

I am trying to copy certain elements (instances) from one project into another. The types from the copied project will already exist and be loaded into the new one.

 

I have managed to copy the elements in their correct location using ElementTransformUtils.CopyElements(), but I am struggling with copying the type parameters (like, for example, the Description and the Type Mark) and the instance parameters (like the Comments or the Mark).

 

The idea is to process all kinds of instances, may they be system types or family symbols, and I have tried using Element.GetOrderedParameters() and LookupParameter("ParameterName") in both types and elements and setting them from the copy project to the paste project using Parameter.AsValueString() and Parameter.SetValueString() respectively.

 

So here goes the question:

Is it possible to copy these type and instance parameters without having to look for them by name, and in a generic manner without having to make distinctions between types and symbols?

If so, any and all tips would be appreciated.

 

Thanks

0 Likes

Copying elements, types and parameters

Hello

 

I am trying to copy certain elements (instances) from one project into another. The types from the copied project will already exist and be loaded into the new one.

 

I have managed to copy the elements in their correct location using ElementTransformUtils.CopyElements(), but I am struggling with copying the type parameters (like, for example, the Description and the Type Mark) and the instance parameters (like the Comments or the Mark).

 

The idea is to process all kinds of instances, may they be system types or family symbols, and I have tried using Element.GetOrderedParameters() and LookupParameter("ParameterName") in both types and elements and setting them from the copy project to the paste project using Parameter.AsValueString() and Parameter.SetValueString() respectively.

 

So here goes the question:

Is it possible to copy these type and instance parameters without having to look for them by name, and in a generic manner without having to make distinctions between types and symbols?

If so, any and all tips would be appreciated.

 

Thanks

Labels (7)
3 REPLIES 3
Message 2 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @franjavigarciavalencia ,

I don't see any problem in copying the element and its instance parameter value from one document to another. 

 

When I try to copy the element from one document to another document, I see along with the element, the element's instance parameter, and its value is also copied.

 

I tried to copy the element's type parameter and its value from one document to another Via UI. I have no luck.

 

please be aware that the Revit API hardly ever supports any functionality that is not also available in the user interface.

 

Therefore, if the UI does not support this, the API will probably not do so either.

 

So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.

 

I hope this clarifies.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Hi @franjavigarciavalencia ,

I don't see any problem in copying the element and its instance parameter value from one document to another. 

 

When I try to copy the element from one document to another document, I see along with the element, the element's instance parameter, and its value is also copied.

 

I tried to copy the element's type parameter and its value from one document to another Via UI. I have no luck.

 

please be aware that the Revit API hardly ever supports any functionality that is not also available in the user interface.

 

Therefore, if the UI does not support this, the API will probably not do so either.

 

So, it will always help to research the optimal manual approach to a solution first, before attacking the task programmatically.

 

I hope this clarifies.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
Sean_Page
in reply to: naveen.kumar.t

Sean_Page
Collaborator
Collaborator
Accepted solution

I have several routines that I use to.copy Loadable as well as system family Types from template or linked models and all of the Parameters always come with them. Perhaps it would help to get the instance, then it's type and copy the type and then the instance?

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect

I have several routines that I use to.copy Loadable as well as system family Types from template or linked models and all of the Parameters always come with them. Perhaps it would help to get the instance, then it's type and copy the type and then the instance?

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
Message 4 of 4

jeremy_tammik
Autodesk
Autodesk
Accepted solution

I just came across this thread in another conversation:

 

https://forums.autodesk.com/t5/revit-api-forum/phasecreated-amp-phasedemolished-after-using-copyelem...

 

I'll add the suggestion that I made there here as well:

 

I believe that when you collect a bunch of elements and copy them all together in one single operation, Revit will try to maintain and restore all their mutual relationships in the target database. Therefore, it might help if you add all possible references these elements have to other source database elements to the set of elements to copy. These references will include the element instances themselves, their types, phases, levels, views, materials, and whatever other objects you are interested in. Then you will have to test and see what Revit can do to try to avoid creating duplicates of them in the target database and map them to existing target objects instead.

 

This behaviour is hinted at in the list of extensible storage features:

   

https://thebuildingcoder.typepad.com/blog/2011/06/extensible-storage-features.html#7

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

I just came across this thread in another conversation:

 

https://forums.autodesk.com/t5/revit-api-forum/phasecreated-amp-phasedemolished-after-using-copyelem...

 

I'll add the suggestion that I made there here as well:

 

I believe that when you collect a bunch of elements and copy them all together in one single operation, Revit will try to maintain and restore all their mutual relationships in the target database. Therefore, it might help if you add all possible references these elements have to other source database elements to the set of elements to copy. These references will include the element instances themselves, their types, phases, levels, views, materials, and whatever other objects you are interested in. Then you will have to test and see what Revit can do to try to avoid creating duplicates of them in the target database and map them to existing target objects instead.

 

This behaviour is hinted at in the list of extensible storage features:

   

https://thebuildingcoder.typepad.com/blog/2011/06/extensible-storage-features.html#7

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report