public static SpaceBoundary[] SpaceBoundaryFromRevitArea(ADSK.Area area, Document doc, View view = null) { if (view == null) { view = GetViewWhereElemIsVisible(doc, area); } var geom = area.get_Geometry(new Options() { View = view }); var solid = geom.Where(g => typeof(ADSK.Solid) == g.GetType()).Cast <ADSK.Solid>().Where(s => s != null); var face = solid.First().Faces.get_Item(0) as PlanarFace; var boundaries = new List <SpaceBoundary>(); foreach (var p in face.GetProfiles(true)) { var boundary = new SpaceBoundary(p, new Elements.Geometry.Transform(), BuiltInMaterials.Default, null, false, Guid.NewGuid(), ""); boundaries.Add(boundary); } return(boundaries.ToArray()); }
/// <summary> /// Construct an Element from an existing Element in the Document /// </summary> /// <param name="area"></param> /// <param name="isRevitOwned"></param> /// <returns></returns> internal static Area FromExisting(Autodesk.Revit.DB.Area area, bool isRevitOwned) { return(new Area(area) { IsRevitOwned = isRevitOwned }); }
/// <summary> /// This node will retrieve the area's solid geometry. /// </summary> /// <param name="area">The area to extract solid from.</param> /// <param name="areaHeight">A manually input area height. Default value is 10.</param> /// <returns name="solid">The solid.</returns> /// <search> /// Area.Boundaries /// </search> public static Solid Solid(global::Revit.Elements.Element area, double areaHeight = 10.0) { Autodesk.Revit.DB.Area internalArea = (Autodesk.Revit.DB.Area)area.InternalElement; var boundaries = new List <List <Autodesk.DesignScript.Geometry.Curve> >(); foreach (var segments in internalArea.GetBoundarySegments(new SpatialElementBoundaryOptions())) { var boundary = new List <Autodesk.DesignScript.Geometry.Curve>(); foreach (Autodesk.Revit.DB.BoundarySegment segment in segments) { boundary.Add(segment.GetCurve().ToProtoType()); } boundaries.Add(boundary); } Autodesk.DesignScript.Geometry.Solid solid = null; List <Autodesk.DesignScript.Geometry.Solid> solidCollection = new List <Solid>(); int flag = 0; while (flag < boundaries.Count) { if (flag == 0) { List <Point> pointList = new List <Point>(); foreach (Autodesk.DesignScript.Geometry.Curve b in boundaries[flag]) { pointList.Add(b.StartPoint); } Polygon polycurveOutline = Polygon.ByPoints(pointList); solid = polycurveOutline.ExtrudeAsSolid(Vector.ByCoordinates(0, 0, 1), areaHeight); } else { List <Point> pointList = new List <Point>(); foreach (Autodesk.DesignScript.Geometry.Curve b in boundaries[flag]) { pointList.Add(b.StartPoint); } Polygon polycurveOutlineVoid = Polygon.ByPoints(pointList); solidCollection.Add(polycurveOutlineVoid.ExtrudeAsSolid(Vector.ByCoordinates(0, 0, 1), areaHeight)); } flag++; } if (solidCollection.Count > 0) { solid = solid.DifferenceAll(solidCollection); } return(solid); }
public static bool ContainsPoint(global::Revit.Elements.Element area, Point point) { Autodesk.Revit.DB.Area internalArea = area.InternalElement as Autodesk.Revit.DB.Area; if (internalArea.Area == 0) { return(false); } XYZ xyz = point.ToXyz(); return(internalArea.AreaContains(xyz)); }
public static List <List <Autodesk.DesignScript.Geometry.Curve> > Boundaries(global::Revit.Elements.Element area) { Autodesk.Revit.DB.Area internalArea = (Autodesk.Revit.DB.Area)area.InternalElement; var boundaries = new List <List <Autodesk.DesignScript.Geometry.Curve> >(); foreach (var segments in internalArea.GetBoundarySegments(new SpatialElementBoundaryOptions())) { var boundary = new List <Autodesk.DesignScript.Geometry.Curve>(); foreach (Autodesk.Revit.DB.BoundarySegment segment in segments) { boundary.Add(segment.GetCurve().ToProtoType()); } boundaries.Add(boundary); } return(boundaries); }
public bool CanConvertToSpeckle(object @object) { return(@object switch { DB.DetailCurve _ => true, DB.DirectShape _ => true, DB.FamilyInstance _ => true, DB.Floor _ => true, DB.Level _ => true, DB.View _ => true, DB.ModelCurve _ => true, DB.Opening _ => true, DB.RoofBase _ => true, DB.Area _ => true, DB.Architecture.Room _ => true, DB.Architecture.TopographySurface _ => true, DB.Wall _ => true, DB.Mechanical.Duct _ => true, DB.Mechanical.Space _ => true, DB.Plumbing.Pipe _ => true, DB.Electrical.Wire _ => true, DB.CurtainGridLine _ => true, //these should be handled by curtain walls DB.Architecture.BuildingPad _ => true, DB.Architecture.Stairs _ => true, DB.Architecture.StairsRun _ => true, DB.Architecture.StairsLanding _ => true, DB.Architecture.Railing _ => true, DB.Architecture.TopRail _ => true, DB.Ceiling _ => true, DB.PointCloudInstance _ => true, DB.Group _ => true, DB.ProjectInfo _ => true, DB.ElementType _ => true, DB.Grid _ => true, DB.ReferencePoint _ => true, DB.Structure.AnalyticalModelStick _ => true, DB.Structure.AnalyticalModelSurface _ => true, DB.Structure.BoundaryConditions _ => true, _ => (@object as Element).IsElementSupported() });
//public List<ApplicationPlaceholderObject> AreaToNative(BuiltElements.Area speckleArea) //{ // var revitRoom = GetExistingElementByApplicationId(speckleArea.applicationId) as DB.Area; // var level = LevelToNative(speckleArea.level); // //TODO: support updating rooms // if (revitRoom != null) // { // Doc.Delete(revitRoom.Id); // } // revitRoom = Doc.Create.NewArea(level, new UV(speckleArea.center.x, speckleArea.center.y)); // revitRoom.Name = speckleArea.name; // revitRoom.Number = speckleArea.number; // SetInstanceParameters(revitRoom, speckleArea); // var placeholders = new List<ApplicationPlaceholderObject>() // { // new ApplicationPlaceholderObject // { // applicationId = speckleArea.applicationId, // ApplicationGeneratedId = revitRoom.UniqueId, // NativeObject = revitRoom // } // }; // return placeholders; //} public BuiltElements.Area AreaToSpeckle(DB.Area revitArea) { var profiles = GetProfiles(revitArea); var speckleArea = new BuiltElements.Area(); speckleArea.name = revitArea.get_Parameter(BuiltInParameter.ROOM_NAME).AsString(); speckleArea.number = revitArea.Number; speckleArea.center = (Point)LocationToSpeckle(revitArea); speckleArea.level = ConvertAndCacheLevel(revitArea, BuiltInParameter.ROOM_LEVEL_ID); speckleArea.outline = profiles[0]; speckleArea.area = GetParamValue <double>(revitArea, BuiltInParameter.ROOM_AREA); if (profiles.Count > 1) { speckleArea.voids = profiles.Skip(1).ToList(); } GetAllRevitParamsAndIds(speckleArea, revitArea); speckleArea.displayMesh = GetElementDisplayMesh(revitArea); return(speckleArea); }
public static Area Wrap(Autodesk.Revit.DB.Area ele, bool isRevitOwned) { return(Area.FromExisting(ele, isRevitOwned)); }
public static global::Revit.Elements.Element AreaScheme(global::Revit.Elements.Element area) { Autodesk.Revit.DB.Area internalArea = area.InternalElement as Autodesk.Revit.DB.Area; return(internalArea.AreaScheme.ToDSType(true)); }
/// <summary> /// Set the internal Revit representation and update the ElementId and UniqueId /// </summary> /// <param name="area"></param> private void InternalSetArea(Autodesk.Revit.DB.Area area) { this.InternalArea = area; this.InternalElementId = area.Id; this.InternalUniqueId = area.UniqueId; }
private void InitArea(Autodesk.Revit.DB.Area area) { InternalSetArea(area); }
private Area(Autodesk.Revit.DB.Area area) { SafeInit(() => InitArea(area)); }