/***************************************************/ private static FamilyInstance FamilyInstance_WorkPlaneBased(Document document, FamilySymbol familySymbol, Curve curve, Element host, RevitSettings settings) { Line line = curve as Line; if (line == null) { familySymbol.LinearOnlyError(); return(null); } Line location; Reference reference; if (host != null) { location = host.ClosestLineOn(line, out reference); } else { location = line; Level level = document.LevelBelow(line, settings); if (level == null) { return(null); } reference = level.GetPlaneReference(); } if (location == null || reference == null) { return(null); } FamilyInstance familyInstance = document.Create.NewFamilyInstance(reference, location, familySymbol); if (familyInstance == null) { return(null); } if (host == null) { familyInstance.CurveBasedNonHostedWarning(); } else { familyInstance.CurveBasedHostedWarning(); } return(familyInstance); }