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.
Hi,
Is it possible and I haven’t had any success trying so far, to find a room using ray projection from a wall/ curtain wall that is a bounding wall on the room’s perimeter?
Here is the code that I have attempted to use.
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_Rooms);
ReferenceIntersector refIntersector = new ReferenceIntersector(filter, FindReferenceTarget.Element, view3d);
ReferenceWithContext referenceWithContext = refIntersector.FindNearest(CurtainWallcurveCenter, wallorientation);
oh revit 2017.1 is my revit version
Hi Nik,
The documentation for ReferenceIntersector says: An instance of this class can be constructed to return any 3D geometric element that intersects the ray created by the origin and direction
I don’t think rooms are considered a “3D geometric element” so will not be found. But there may be other ways to accomplish your goal. What are you trying to do?
Harry
Hi Harry,
I thought so, It would have been the easy method however.
So what I am trying to get the room as an element on the inside of a curtainWall wall that is on the rooms perimeter. My next attempt will be to use the wall orientation property and do a transform/ translation of the CW’s bounding box into the room on the interior side of the CW. unless you know an easier method?
Have you tried looking at SpatialElement.GetBoundarySegments and comparing that to the LocationCurve of the wall?
aah i see you have a post on the aforementioned. Cool