Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Sample for Rehost API

Balaji_07
Advocate

Sample for Rehost API

Balaji_07
Advocate
Advocate

We are facing issues when we try to copy and paste walls and its hosted element using

ElementTransformUtils.CopyElements

method. The resulting hosted elements are not associated to wall.

 

So, I am looking for a sample/code snippet for Rehost API and unable to find any sample.

The below link has the documentation for rehost method but I could not find related code samples.

https://www.revitapidocs.com/2023/a222958c-4b12-075b-ade4-d78642c40d90.htm

 

I am not able to create an object for Autodesk.Revit.DB.Form class to call the rehost method. Form class does not have any constructor.

Any suggestion or code snipped is highly appreciated.

 

Thanks.

Balaji A

 

 

Reply
290 Views
1 Reply
Reply (1)

RPTHOMAS108
Mentor
Mentor

'Form' is something used in a family e.g. extrusion.

 

There is no re-hosting API as far as I know (for re-hosting in project).

 

The ElementTransformUtils is supposed to do re-hosting for some overloads but not others:

 

ElementTransformUtils.CopyElements(Document, ICollection<ElementId>, XYZ)
"This method is not suitable for elements that are hosted in other elements as it does not perform rehosting. If you need to rehost your elements in addition to copying them, use one of the other CopyElements() overloads. "


ElementTransformUtils.CopyElements(Document, ICollection<ElementId>, Document, Transform, CopyPasteOptions)
"The destination document can be the same as the source document."
"This method performs rehosting of elements where applicable."