Hi @Anonymous ,
try using the below code
//helps you to select an element(door,window) in the linked document
Reference R = uidoc.Selection.PickObject(ObjectType.LinkedElement);
Document linkedDoc = null;
foreach(Document d in app.Documents)
{
//get the linked document
if(d.IsLinked)
{
linkedDoc = d as Document;
}
}
Element e = linkedDoc.GetElement(R.LinkedElementId);
FamilyInstance Fi = e as FamilyInstance;
Element host = Fi.Host as Element;
string wallName = host.Name;
if there are too many linked documents in the project use
//get the linked document
if(d.IsLinked && d.Title=="Your linked document name")
{
linkedDoc = d as Document;
}
The important points are
1)To select an object in linked document you have to use object type as LinkedElement
2)Get the linked document not the main document
3)from the linked document using the linked element id get the element present in the linked document
If you have any doubts , feel free to ask
I hope this helps.
Naveen Kumar T
Developer Technical Services
Autodesk Developer Network