Get linked element reference

Get linked element reference

ottosson_mathias
Advocate Advocate
901 Views
2 Replies
Message 1 of 3

Get linked element reference

ottosson_mathias
Advocate
Advocate

Is it possible to get the element Reference object for an element in a linked model same as if I use the uiDoc.Selection.PickObject(...) on the linked model?

 

PickObject returns a Reference object, and I need this reference objects after I've used filteredElementCollector for all elements I need in the linked model.

 

How can I achieve this?

0 Likes
Accepted solutions (1)
902 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

Look at the Reference class members:

   

   

Among others, they include:

   

  • CreateLinkReference -- Creates a Reference from a Reference in an RVT Link.
  • CreateReferenceInLink -- Creates a Reference in an RVT Link from a Reference in the RVT host file.
  • LinkedElementId -- The id of the top-level element in the linked document that is referred to by this reference.

   

Here are some articles on making use of them:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

ottosson_mathias
Advocate
Advocate

Thanks Jeremy.

This seems to do the trick:

var reference = new Reference(elementFromLinkedModel);
var linkReference = reference.CreateLinkReference(linkInstance);