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:
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.