Get room data for elements in RVT links

A Revit guru asked:

“Have you ever shared room data across Revit links successfully? If you have 10 linked projects from different authors / disciplines, and the official room data only exists in one of them (say architectural), have you figured out a way to create a cross discipline room schedule?”

For example, your walls & rooms are in rooms.rvt. Furniture is in furniture.rvt which is linked into rooms.rvt. How do you figure out the room for each piece of furniture?

With the API, of course!

Sometimes its not your code (try a different Revit version)

An API developer asked why this code didn’t work to place a face-based family instance on a face in an RVT Link.

public void PlaceFaceBasedFamilyinLink()
{
    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;
    
    ReferenceIntersector ri = new ReferenceIntersector((View3D)doc.ActiveView);
    ri.FindReferencesInRevitLinks = true;
    Reference r = ri.FindNearest(XYZ.Zero,XYZ.BasisZ.Negate()).GetReference();

    Family fam = new FilteredElementCollector(doc).OfClass(typeof(Family)).Cast<Family>().FirstOrDefault(q => q.Name == "Family2");
    
    using (Transaction t = new Transaction(doc,"place instance"))
    {
        t.Start();
        doc.Create.NewFamilyInstance(r, r.GlobalPoint, XYZ.BasisY, fam.Symbols.Cast<FamilySymbol>().First());
        t.Commit();
    }        
}

After investigating for a while in 2014 and wondering why this error occurred:

Capture

I decided to try the same codeĀ in 2015 where I found it to work just fine. This doesn’t help me get it working if I need a Revit 2014 solution, but at least it lets me stop spendingĀ time looking for a problem in my code that doesn’t exist.