How to get the picked element in the linked model

Joe Ye

In Revit 2014, developers can call the PickObject(ObjectType.LinkedElement) to pick element in the linked model. Many developers love that. One question is how to get the picked element. They use the ElementId in the returned Reference.ElementId cannot successfully get the target element.

Actually in along with addition of ObjectType.LinkedElement enum member, Reference class also has one new member, LinkedElementId. Through this property, you can get the right ElementId of the linked document.

Here is the minimum code fragment to show the idea.

<code>

Document docLinked = null;

Reference refElemLinked =uiDoc.Selection.PickObject(ObjectType.LinkedElement,”Please pick an element in the linked model”);

//Add code to get linked document here.

Element elem = linkedDoc.GetElement(refElemLinked.LinkedElementId);

<code>


Comments

3 responses to “How to get the picked element in the linked model”

  1. Michael Avatar
    Michael

    Can you help out with the part about //Add code to get linked document? What’s the easiest way to get the document from the picked linked element? Thanks.

  2. Hi,
    How can I select an element in the linked model? I already have the elementID, but cannot figure out how to select it in the current view.
    Thanks!

  3. Paolo Modenese Avatar
    Paolo Modenese

    Just what i was looking for. Thank you!!

Leave a Reply