/// <summary> /// Create a Revit Floor given it's curve outline and Level /// </summary> /// <param name="outline"></param> /// <param name="level"></param> /// <returns>The floor</returns> public static Floor ByOutlineTypeAndLevel( Autodesk.DesignScript.Geometry.Curve[] outline, FloorType floorType, Level level) { if (outline == null) { throw new ArgumentNullException("outline"); } if (floorType == null) { throw new ArgumentNullException("floorType"); } if ( level == null ) { throw new ArgumentNullException("level"); } if (outline.Count() < 3) { throw new Exception("Outline must have at least 3 edges to enclose an area."); } var ca = new CurveArray(); outline.ToList().ForEach(x => ca.Append(x.ToRevitType())); return new Floor(ca, floorType.InternalFloorType, level.InternalLevel ); }
public static Dictionary <string, object> AllFloorsOfType(Revit.Elements.FloorType floorType) { Document doc = DocumentManager.Instance.CurrentDBDocument; FilteredElementCollector floorCollector = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType(); var floorCollection = floorCollector.ToElements(); List <Revit.Elements.Element> floorTypes = new List <Revit.Elements.Element>(); foreach (var element in floorCollection) { var floor = (Autodesk.Revit.DB.Floor)element; if (floor.FloorType.Id == floorType.InternalElement.Id) { floorTypes.Add(floor.ToDSType(true)); } } ; //returns the outputs var outInfo = new Dictionary <string, object> { { "floors", floorTypes } }; return(outInfo); }
public static FloorType Wrap(Autodesk.Revit.DB.FloorType ele, bool isRevitOwned) { return(FloorType.FromExisting(ele, isRevitOwned)); }
/// <summary> /// Create a Revit Floor given it's curve outline and Level /// </summary> /// <param name="outlineCurves"></param> /// <param name="floorType"></param> /// <param name="level"></param> /// <returns>The floor</returns> public static Floor ByOutlineTypeAndLevel(Curve[] outlineCurves, FloorType floorType, Level level) { if (outlineCurves == null) { throw new ArgumentNullException("outlineCurves"); } return ByOutlineTypeAndLevel(PolyCurve.ByJoinedCurves(outlineCurves), floorType, level); }
/// <summary> /// Create a Revit Floor given it's curve outline and Level /// </summary> /// <param name="outline"></param> /// <param name="floorType"></param> /// <param name="level"></param> /// <returns>The floor</returns> public static Floor ByOutlineTypeAndLevel(PolyCurve outline, FloorType floorType, Level level) { if (outline == null) { throw new ArgumentNullException("outline"); } if (floorType == null) { throw new ArgumentNullException("floorType"); } if ( level == null ) { throw new ArgumentNullException("level"); } if (!outline.IsClosed) { throw new ArgumentException("The input PolyCurve is not closed"); } var ca = new CurveArray(); outline.Curves().ForEach(x => ca.Append(x.ToRevitType())); return new Floor(ca, floorType.InternalFloorType, level.InternalLevel ); }
public static List <List <DynamoRevitElements.Floor> > CreateRevitFloors( DynamoElements.Surface[][] srfList, DynamoRevitElements.FloorType floorType, string levelPrefixStr = "Dynamo Level") { if (srfList == null) { throw new ArgumentNullException(nameof(srfList)); } if (!(floorType.InternalElement is RevitElements.FloorType revitFloorType)) { throw new ArgumentOutOfRangeException(nameof(floorType)); } DisplayUnitType unitType = Document.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits; var FloorElements = new List <List <DynamoRevitElements.Floor> >(); var collector = new FilteredElementCollector(Document); var levels = collector.OfClass(typeof(RevitElements.Level)).ToElements() .Where(e => e is RevitElements.Level) .Cast <RevitElements.Level>(); TransactionManager.Instance.EnsureInTransaction(Document); for (var i = 0; i < srfList.Length; i++) { if (srfList[i] == null) { throw new ArgumentNullException(nameof(srfList)); } FloorElements.Add(new List <DynamoRevitElements.Floor>()); string levelName = $"{levelPrefixStr} {i + 1}"; var revitLevel = levels.FirstOrDefault(level => level.Name == levelName); double elevation; using (var floorBounds = BoundingBox.ByGeometry(srfList[i])) { elevation = UnitUtils.ConvertToInternalUnits(floorBounds.MaxPoint.Z, unitType); } if (revitLevel != null) { // Adjust existing level to correct height. revitLevel.Elevation = elevation; } else { // Create new level. revitLevel = RevitElements.Level.Create(Document, elevation); revitLevel.Name = levelName; } var revitCurves = new CurveArray(); foreach (var surface in srfList[i]) { var loops = Building.GetSurfaceLoops(surface); revitCurves.Clear(); loops[0].Curves().ForEach(curve => revitCurves.Append(curve.ToRevitType())); var revitFloor = Document.Create.NewFloor(revitCurves, revitFloorType, revitLevel, true); FloorElements.Last().Add(revitFloor.ToDSType(false) as DynamoRevitElements.Floor); // Need to finish creating the floor before we add openings in it. TransactionManager.Instance.ForceCloseTransaction(); TransactionManager.Instance.EnsureInTransaction(Document); loops.Skip(1).ToArray().ForEach(loop => { revitCurves.Clear(); loop.Curves().ForEach(curve => revitCurves.Append(curve.ToRevitType())); Document.Create.NewOpening(revitFloor, revitCurves, true); }); loops.ForEach(x => x.Dispose()); revitFloor.Dispose(); } revitCurves.Dispose(); } TransactionManager.Instance.TransactionTaskDone(); collector.Dispose(); return(FloorElements); }