/// <summary> /// Determine if an element lies /// within the volume of the Room /// </summary> public bool IsInRoom(Element element) { DB.FamilyInstance familyInstance = element.InternalElement as DB.FamilyInstance; if (familyInstance != null) { if (familyInstance.HasSpatialElementCalculationPoint) { DB.XYZ insertionPoint = familyInstance.GetSpatialElementCalculationPoint(); if (InternalRoom.IsPointInRoom(insertionPoint)) { return(true); } else { return(false); } } } DB.LocationPoint insertionLocationPoint = element.InternalElement.Location as DB.LocationPoint; if (insertionLocationPoint != null) { DB.XYZ insertionPoint = insertionLocationPoint.Point; if (InternalRoom.IsPointInRoom(insertionPoint)) { return(true); } } return(false); }
/// <summary> /// Return a grid of points in the room /// </summary> /// <param name="step">Lenght between two points</param> public List <Point> Grid(double step) { step = UnitConverter.DynamoToHostFactor(DB.UnitType.UT_Length) * step; List <Point> grid = new List <Point>(); DB.BoundingBoxXYZ bb = InternalElement.get_BoundingBox(null); for (double x = bb.Min.X; x < bb.Max.X;) { for (double y = bb.Min.Y; y < bb.Max.Y;) { DB.XYZ point = new DB.XYZ(x, y, bb.Min.Z); if (InternalRoom.IsPointInRoom(point)) { grid.Add(GeometryPrimitiveConverter.ToPoint(InternalTransform.OfPoint(point))); } y = y + step; } x = x + step; } return(grid); }