private void createElevationByRoom(Room myRoom) { // Set active document UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; // List View Section // List<ViewSection> myListViewSecton = null; using (Transaction trans = new Transaction(doc, "add elevation")) { trans.Start(); // Show parameter of picked room BoundingBoxXYZ roomBounding = myRoom.get_BoundingBox(null); XYZ minPointBb = roomBounding.Min; // TaskDialog.Show("Min point", Math.Round(minPointBb.X,0).ToString() + "," + Math.Round(minPointBb.Y,0).ToString()+"," + minPointBb.Z.ToString()); // TaskDialog.Show("Max point", Math.Round(minPointBb.X,0).ToString() + "," + Math.Round(minPointBb.Y,0).ToString()+"," + minPointBb.Z.ToString()); // Get parameter of room double myLevel = myRoom.Level.Elevation; BoundingBoxXYZ myRoomBB = myRoom.get_BoundingBox(null); XYZ maxPointBB = myRoomBB.Max; XYZ minPointBB = myRoomBB.Min; // TaskDialog.Show("abc","Level: " + myLevel.ToString() + "Min: " + minPointBB.ToString()); LocationPoint lcPointRoom = myRoom.Location as LocationPoint; XYZ originPoint = lcPointRoom.Point; XYZ OriginPoint2 = new XYZ((maxPointBB.X + minPointBb.X) / 2, (maxPointBB.Y + minPointBb.Y) / 2, originPoint.Z); // second parameter in contructor ElevationMarker ViewFamilyType vft = new FilteredElementCollector(doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() .FirstOrDefault <ViewFamilyType>(x => ViewFamily.Elevation == x.ViewFamily); ElementId myEleId = vft.Id; // Tao 1 ElevationMaker ElevationMarker myELM = ElevationMarker.CreateElevationMarker(doc, myEleId, originPoint, 40); myRoomBB.Min = new XYZ(myRoomBB.Min.X, myRoomBB.Min.Y, myRoom.Level.Elevation); myRoomBB.Max = new XYZ(myRoomBB.Max.X, myRoomBB.Max.Y, myRoom.Level.Elevation + 1); // TaskDialog.Show("Abc", myRoom.Level.Elevation.ToString()); for (int i = 0; i < 4; i++) { ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); string roomsName = myRoom.Name.Substring(0, myRoom.Name.Length - 1 - myRoom.Number.ToString().Length); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); // TaskDialog.Show("abc", myELM.Name.ToString()); elevationView.CropBoxActive = true; // Set style // setStyleCropBoxFromView(elevationView); BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); if (i == 0) { myCrop.Min = new XYZ(myRoomBB.Min.Y - 1, myRoom.Level.Elevation - 0.5, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.Y + 1, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 0.5, myCrop.Max.Z); elevationView.CropBox = myCrop; // doc.ActiveView.SetElementOverrides(elevationView.Id,ogs); // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } else if (i == 1) { myCrop.Min = new XYZ(myRoomBB.Min.X - 1, myRoom.Level.Elevation - 0.5, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.X + 1, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 0.5, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } // mai xu li else if (i == 2) { double XMin = -(Math.Abs(maxPointBB.Y - minPointBb.Y) / 2) - 1; double XMax = +(Math.Abs(maxPointBB.Y - minPointBb.Y) / 2) + 1; myCrop.Min = new XYZ(XMin - OriginPoint2.Y, myRoom.Level.Elevation - 0.5, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.Y - myRoomBB.Min.Y + 2, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 0.5, myCrop.Max.Z); // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; elevationView.CropBox = myCrop; } else { myCrop.Min = new XYZ(myRoomBB.Min.X - 1 - 2 * (OriginPoint2.X), myRoom.Level.Elevation - 0.5, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.X - myRoomBB.Min.X + 2, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 0.5, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } } trans.Commit(); } }
private void createElevationByRoom2(Room myRoom) { // Set active document UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; // List View Section List <ViewSection> myListViewSecton = new List <ViewSection>(); ElevationMarker myELM = null; BoundingBoxXYZ myRoomBB = null; XYZ minPointBB = null; XYZ maxPointBB = null; XYZ minPointBb = null; XYZ OriginPoint2 = null; // XYZ OriginPoint = null; using (Transaction trans0 = new Transaction(doc, "Create a new Elevation Marker")) { trans0.Start(); // Show parameter of picked room BoundingBoxXYZ roomBounding = myRoom.get_BoundingBox(null); minPointBb = roomBounding.Min; // Get parameter of room double myLevel = myRoom.Level.Elevation; myRoomBB = myRoom.get_BoundingBox(null); maxPointBB = myRoomBB.Max; minPointBB = myRoomBB.Min; LocationPoint lcPointRoom = myRoom.Location as LocationPoint; XYZ originPoint = lcPointRoom.Point; OriginPoint2 = new XYZ((maxPointBB.X + minPointBb.X) / 2, (maxPointBB.Y + minPointBb.Y) / 2, originPoint.Z); // second parameter in contructor ElevationMarker ViewFamilyType vft = new FilteredElementCollector(doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() .FirstOrDefault <ViewFamilyType>(x => ViewFamily.Elevation == x.ViewFamily); ElementId myEleId = vft.Id; // Tao 1 ElevationMaker myELM = ElevationMarker.CreateElevationMarker(doc, myEleId, originPoint, 40); myRoomBB.Min = new XYZ(myRoomBB.Min.X, myRoomBB.Min.Y, myRoom.Level.Elevation); myRoomBB.Max = new XYZ(myRoomBB.Max.X, myRoomBB.Max.Y, myRoom.Level.Elevation + 1); trans0.Commit(); } // string roomsName = myRoom.Name.Substring(0, myRoom.Name.Length - 1 - myRoom.Number.ToString().Length); string roomsName = myRoom.Name.ToString(); for (int i = 0; i < 4; i++) { if (i == 0) { using (Transaction trans1 = new Transaction(doc, "create sec 0")) { trans1.Start(); ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); elevationView.CropBoxActive = true; BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); myCrop.Min = new XYZ(myRoomBB.Min.Y - 1, myRoom.Level.Elevation - 1, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.Y + 1, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 1, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; trans1.Commit(); //add View to List View myListViewSecton.Add(elevationView); } } else if (i == 1) { using (Transaction trans2 = new Transaction(doc, "create sec 1")) { trans2.Start(); ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); elevationView.CropBoxActive = true; BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); myCrop.Min = new XYZ(myRoomBB.Min.X - 1, myRoom.Level.Elevation - 1, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.X + 1, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 1, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; trans2.Commit(); //add View to List View myListViewSecton.Add(elevationView); } } // mai xu li else if (i == 2) { using (Transaction trans3 = new Transaction(doc, "create sec 2")) { trans3.Start(); ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); elevationView.CropBoxActive = true; BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); double XMin = -(Math.Abs(maxPointBB.Y - minPointBb.Y) / 2) - 1; double XMax = +(Math.Abs(maxPointBB.Y - minPointBb.Y) / 2) + 1; myCrop.Min = new XYZ(XMin - OriginPoint2.Y, myRoom.Level.Elevation - 1, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.Y - myRoomBB.Min.Y + 2, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 1, myCrop.Max.Z); // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; elevationView.CropBox = myCrop; trans3.Commit(); //add View to List View myListViewSecton.Add(elevationView); } } else { using (Transaction trans4 = new Transaction(doc, "create sec 3")) { trans4.Start(); ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); elevationView.CropBoxActive = true; BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); myCrop.Min = new XYZ(myRoomBB.Min.X - 1 - 2 * (OriginPoint2.X), myRoom.Level.Elevation - 1, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.X - myRoomBB.Min.X + 2, myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 1, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; trans4.Commit(); //add View to List View myListViewSecton.Add(elevationView); } } } // TaskDialog.Show("abc", "my List view create: " + myListViewSecton.Count().ToString()); foreach (ViewSection mySec in myListViewSecton) { // using (Transaction trans11 = new Transaction(doc, "Chang style for cropBox")) // { // trans11.Start(); setStyleCropBoxFromView(mySec); // trans11.Commit(); // } } }
/// <summary> /// 在房间X的中心创建四个方向的立面 /// Create four Elevations on the center of the "X" of the selRoom /// </summary> /// <param name="elevationOffset"></param> /// <param name="FloorThickness"></param> public void CreateElevations(double elevationOffset, double FloorThickness) { int i = 0;//循环用 //获取立面的familytype Get the familyType of Elevation FilteredElementCollector collector = new FilteredElementCollector(DocSet.doc); collector.OfClass(typeof(ViewFamilyType)); var viewFamilyTypes = from elem in collector let type = elem as ViewFamilyType where type.ViewFamily == ViewFamily.Elevation select type; ElementId viewTypeId; if (viewFamilyTypes.Count() > 0) { viewTypeId = viewFamilyTypes.First().Id; } else { return; } using (Transaction tran = new Transaction(DocSet.doc)) { //房间的"X"的交点 LocationPoint pt = DocSet.selRoom.Location as LocationPoint; tran.Start("newElvation"); ElevationMarker marker = ElevationMarker.CreateElevationMarker(DocSet.doc, viewTypeId, pt.Point, 50); for (; i < 4; i++) { ViewSection sv = marker.CreateElevation(DocSet.doc, DocSet.doc.ActiveView.Id, i); //设定立面的 远剪裁偏移 sv.get_Parameter(BuiltInParameter.VIEWER_BOUND_OFFSET_FAR).SetValueString("10000"); //设定每个立面的名称 XYZ normal = null;//法向量 string elevationName = "ELE -"; switch (i) { case 0: elevationName += " West " + _SoANumber; normal = new XYZ(-1, 0, 0); sv.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set("ELEVATION WEST"); break; case 1: elevationName += " North" + _SoANumber; normal = new XYZ(0, 1, 0); sv.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set("ELEVATION NORTH"); break; case 2: elevationName += " East" + _SoANumber; normal = new XYZ(1, 0, 0); sv.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set("ELEVATION EAST"); break; case 3: elevationName += " South" + _SoANumber; normal = new XYZ(0, -1, 0); sv.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set("ELEVATION SOUTH"); break; } sv.ViewName = elevationName; //不能删 必须先保存修改才能获取上面的元素 tran.Commit(); tran.Start("change elevation crop shape"); //小指型房间专用修改 if (cbSpRoom.IsChecked == true) { if (i == 1 || i == 2) { normal = -normal; } spRoomElevationChange(sv, elevationOffset, normal, FloorThickness); } else { //修改立面底边的高度 XYZ pt1 = null; XYZ pt2 = null; XYZ pt3 = null; XYZ pt4 = null; sv.CropBoxActive = true; ViewCropRegionShapeManager vcrShanpMgr = sv.GetCropRegionShapeManager(); CurveLoop loop = vcrShanpMgr.GetCropShape().First(); CurveLoopIterator iterator = loop.GetCurveLoopIterator(); //分辨点的位置 while (iterator.MoveNext()) { Curve curve = iterator.Current; XYZ pt0 = curve.GetEndPoint(0); if (-1 < pt0.Z - pt.Point.Z && pt0.Z - pt.Point.Z < 1) { if (pt1 == null) { pt1 = pt0; } else { pt2 = pt0; } } else { if (pt3 == null) { pt3 = pt0; } else { pt4 = pt0; } } } //重新生成一个边界框 //TaskDialog.Show("1", pt1.ToString() + "\n" + pt2.ToString() + "\n" + pt3.ToString() + "\n" + pt4.ToString()); pt1 = new XYZ(pt1.X, pt1.Y, pt1.Z + FloorThickness / 300); pt2 = new XYZ(pt2.X, pt2.Y, pt1.Z); Line lineBottom = Line.CreateBound(pt1, pt2); Line lineRight = Line.CreateBound(pt2, pt4); Line lineTop = Line.CreateBound(pt4, pt3); Line lineLeft = Line.CreateBound(pt3, pt1); CurveLoop profile = new CurveLoop(); profile.Append(lineBottom); profile.Append(lineRight); profile.Append(lineTop); profile.Append(lineLeft); profile = CurveLoop.CreateViaOffset(profile, elevationOffset / 300, -normal); vcrShanpMgr.SetCropShape(profile); } } tran.Commit(); } }
/// <summary> /// Nhận vào 2 tham số, trả về null khi tạo 4 mặt đứng bằng instance thuộc lớp ElevationMarker /// </summary> /// <param name="uiDoc"></param> /// <param name="myRoom"></param> private void createElevationByRoom(UIDocument uiDoc, Room myRoom) { // Set active document Document doc = uiDoc.Document; using (Transaction trans = new Transaction(doc, "add elevation")) { // Start Transaction trans.Start(); // Get parameter of room double myLevel = myRoom.Level.Elevation; // Get BoundingBoxXYZ of the room. BoundingBoxXYZ myRoomBB = myRoom.get_BoundingBox(null); XYZ maxPointBB = myRoomBB.Max; XYZ minPointBB = myRoomBB.Min; //Set Origin View Point as rooms Location Point LocationPoint lcPointRoom = myRoom.Location as LocationPoint; XYZ originPoint = lcPointRoom.Point; // Get Center Point of room to make reference Point of views XYZ OriginPoint2 = new XYZ((maxPointBB.X + minPointBB.X) / 2, (maxPointBB.Y + minPointBB.Y) / 2, originPoint.Z); // second parameter in contructor ElevationMarker ViewFamilyType vft = new FilteredElementCollector(doc) .OfClass(typeof(ViewFamilyType)) .Cast <ViewFamilyType>() .FirstOrDefault <ViewFamilyType>(x => ViewFamily.Elevation == x.ViewFamily); ElementId myEleId = vft.Id; // Create 1 ElevationMaker with scale = 1:40, type View = Elevation ElevationMarker myELM = ElevationMarker.CreateElevationMarker(doc, myEleId, originPoint, 40); // Set max and Min Elevation of View (axis Y of Section Views), offset = 1 feet; double minY = myRoom.Level.Elevation - 1; // offset - 1 double maxY = myRoom.UpperLimit.Elevation + myRoom.LimitOffset + 1; //offset + 1 for (int i = 0; i < 4; i++) { ViewSection elevationView = myELM.CreateElevation(doc, doc.ActiveView.Id, i); string roomsName = myRoom.Name.Substring(0, myRoom.Name.Length - 1 - myRoom.Number.ToString().Length); elevationView.Name = roomsName.ToUpper() + ", Section ".ToUpper() + i.ToString().ToUpper(); elevationView.CropBoxActive = true; elevationView.DisplayStyle = DisplayStyle.Realistic; BoundingBoxXYZ myCrop = elevationView.get_BoundingBox(null); if (i == 0) { // Case 1: LeftView myCrop.Min = new XYZ(myRoomBB.Min.Y - 1, minY, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.Y + 1, maxY, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } else if (i == 1) { //Case 2: Above View myCrop.Min = new XYZ(myRoomBB.Min.X - 1, minY, myCrop.Min.Z); myCrop.Max = new XYZ(myRoomBB.Max.X + 1, maxY, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style for View elevationView.DisplayStyle = DisplayStyle.HLR; } // Case 3, 4 make OriginPoint2 as reference Point else if (i == 2) { // double XMin = -(Math.Abs(maxPointBB.Y - minPointBB.Y) / 2) - 1; double XMax = +(Math.Abs(maxPointBB.Y - minPointBB.Y) / 2) + 1; myCrop.Min = new XYZ(XMin - OriginPoint2.Y, minY, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.Y - myRoomBB.Min.Y + 2, maxY, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } else { myCrop.Min = new XYZ(myRoomBB.Min.X - 1 - 2 * (OriginPoint2.X), minY, myCrop.Min.Z); myCrop.Max = new XYZ(myCrop.Min.X + myRoomBB.Max.X - myRoomBB.Min.X + 2, maxY, myCrop.Max.Z); elevationView.CropBox = myCrop; // Set visual style elevationView.DisplayStyle = DisplayStyle.HLR; } } trans.Commit(); } }
public static List <List <Revit.Elements.Element> > ElevationInRoom(List <Revit.Elements.Room> Rooms, Revit.Elements.Element FloorPlan, double Offset = 500) { var doc = DocumentManager.Instance.CurrentDBDocument; var vtype = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast <ViewFamilyType>().FirstOrDefault(a => a.ViewFamily == ViewFamily.Elevation); var ElevationView = new List <List <Revit.Elements.Element> >(); TransactionManager.Instance.EnsureInTransaction(doc); foreach (var r in Rooms) { var list = new List <Revit.Elements.Element>(); var elevViews = new List <Revit.Elements.Element>(); String rname = r.InternalElement.LookupParameter("Number").AsString() + "_" + r.InternalElement.LookupParameter("Name").AsString(); LocationPoint elevPoint = (Autodesk.Revit.DB.LocationPoint)r.InternalElement.Location; XYZ point = elevPoint.Point; BoundingBoxXYZ bbox = r.InternalElement.get_BoundingBox(doc.ActiveView); ElevationMarker marker = Autodesk.Revit.DB.ElevationMarker.CreateElevationMarker(doc, vtype.Id, point, 50); BoundingBoxXYZ bcrop = Utility.Crop_box(bbox, Offset / 304.8); var surfaces = bcrop.ToProtoType(true).ToPolySurface().Surfaces().Skip(2).Take(4); var westElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 0); westElev.Name = rname + " - A"; var westcrsm = westElev.GetCropRegionShapeManager(); var west = surfaces.ElementAt(0).PerimeterCurves(); var westcurve = new List <Autodesk.Revit.DB.Curve>(); foreach (var w in west) { westcurve.Add(w.ToRevitType(true)); } CurveLoop wcloop = CurveLoop.Create(westcurve); westcrsm.SetCropShape(wcloop); var northElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 1); northElev.Name = rname + " - B"; var northcrsm = northElev.GetCropRegionShapeManager(); var north = surfaces.ElementAt(1).PerimeterCurves(); var northcurve = new List <Autodesk.Revit.DB.Curve>(); foreach (var w in north) { northcurve.Add(w.ToRevitType(true)); } CurveLoop ncloop = CurveLoop.Create(northcurve); northcrsm.SetCropShape(ncloop); var eastElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 2); eastElev.Name = rname + " - C"; var eastcrsm = eastElev.GetCropRegionShapeManager(); var east = surfaces.ElementAt(2).PerimeterCurves(); var eastcurve = new List <Autodesk.Revit.DB.Curve>(); foreach (var w in east) { eastcurve.Add(w.ToRevitType(true)); } CurveLoop ecloop = CurveLoop.Create(eastcurve); eastcrsm.SetCropShape(ecloop); var southElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 3); southElev.Name = rname + " - D"; var southcrsm = southElev.GetCropRegionShapeManager(); var south = surfaces.ElementAt(3).PerimeterCurves(); var southcurve = new List <Autodesk.Revit.DB.Curve>(); foreach (var w in south) { southcurve.Add(w.ToRevitType(true)); } CurveLoop scloop = CurveLoop.Create(southcurve); southcrsm.SetCropShape(scloop); list.Add(westElev.ToDSType(true)); list.Add(northElev.ToDSType(true)); list.Add(eastElev.ToDSType(true)); list.Add(southElev.ToDSType(true)); ElevationView.Add(list); } TransactionManager.Instance.TransactionTaskDone(); return(ElevationView); }
public static void GenViews(ViewFamilyType vft, View av, Room r) { Document currentDoc = r.Document; foreach (ElementId vtd in ViewsToDelete(r)) { if (currentDoc.GetElement(vtd).IsValidObject) { currentDoc.Delete(vtd); } } BoundingBoxXYZ bbse = r.get_BoundingBox(null); double yMin = bbse.Min.Z; double yMax = bbse.Max.Z; BoundaryData BData = new BoundaryData(r); if (null != BData.Edges()) { foreach (KeyValuePair <Line, XYZ> kvp in BData.Edges()) { XYZ start = kvp.Key.GetEndPoint(0); XYZ end = kvp.Key.GetEndPoint(1); XYZ vector = end - start; XYZ midpt = start + (0.5 * vector); double xsize = kvp.Key.Length; double height = yMax - yMin; double minx = midpt.X - (xsize / 2) - offset; double maxx = midpt.X + (xsize / 2) + offset; double miny = yMin - offset; double maxy = yMax + offset; double minz = midpt.Z - offset / 2; double maxz = midpt.Z + offset / 2; XYZ minbound = new XYZ(minx, miny, minz); XYZ maxbound = new XYZ(maxx, maxy, maxz); BoundingBoxXYZ sectionBox = new BoundingBoxXYZ(); sectionBox.Min = minbound; sectionBox.Max = maxbound; ElevationMarker em = ElevationMarker.CreateElevationMarker(currentDoc, vft.Id, midpt, 48); ViewSection vs = em.CreateElevation(currentDoc, av.Id, 1); vs.CropBox = sectionBox; XYZ baseangle = XYZ.BasisY; double rotation = kvp.Value.AngleTo(baseangle); if (kvp.Value.X > 0) { rotation *= -1; } string dir = Direction(rotation); Line axisline = Line.CreateBound(midpt, new XYZ(midpt.X, midpt.Y, midpt.Z + 1)); em.Location.Rotate(axisline, rotation); em.Location.Move(-kvp.Value * offset); int j = 1; bool iscreated = false; while (iscreated == false) { string viewname = r.Name + " - " + dir + " " + j; FilteredElementCollector vfilter = new FilteredElementCollector(currentDoc).OfClass(typeof(View)); View testname = vfilter.FirstOrDefault <Element>(a => a.Name.Equals(viewname)) as View; if (testname == null) { vs.Name = viewname; iscreated = true; } else { j++; } } } } }