/// <summary> /// get all the vertexes of the curtain cells /// </summary> /// <param name="cells"> /// the curtain cells which need to be got the vertexes /// </param> /// <returns> /// the vertexes of the curtain cells /// </returns> private List <Autodesk.Revit.DB.XYZ> GetPoints(CurtainCellSet cells) { List <Autodesk.Revit.DB.XYZ> points = new List <Autodesk.Revit.DB.XYZ>(); if (null == cells || true == cells.IsEmpty) { return(points); } foreach (CurtainCell cell in cells) { if (null == cell || 0 == cell.CurveLoops.Size) { continue; } CurveArray curves = cell.CurveLoops.get_Item(0); foreach (Curve curve in curves) { points.Add(curve.get_EndPoint(0)); points.Add(curve.get_EndPoint(1)); } } return(points); }
/// <summary> /// get the vertexes of the bounding box which covers all the curtain cells /// </summary> /// <param name="cells"> /// the source curtain cells /// </param> /// <param name="minXYZ"> /// the result bounding point /// </param> /// <param name="maxXYZ"> /// the result bounding point /// </param> private void GetVertexesByCells(CurtainCellSet cells, ref Autodesk.Revit.DB.XYZ minXYZ, ref Autodesk.Revit.DB.XYZ maxXYZ) { if (null == cells || true == cells.IsEmpty) { return; } List <Autodesk.Revit.DB.XYZ> points = GetPoints(cells); GetVertexesByPoints(points, ref minXYZ, ref maxXYZ); }
/// <summary> /// get all the vertexes of the curtain cells /// </summary> /// <param name="cells"> /// the curtain cells which need to be got the vertexes /// </param> /// <returns> /// the vertexes of the curtain cells /// </returns> private List<Autodesk.Revit.DB.XYZ> GetPoints(CurtainCellSet cells) { List<Autodesk.Revit.DB.XYZ> points = new List<Autodesk.Revit.DB.XYZ>(); if (null == cells || true == cells.IsEmpty) { return points; } foreach (CurtainCell cell in cells) { if (null == cell || 0 == cell.CurveLoops.Size) { continue; } CurveArray curves = cell.CurveLoops.get_Item(0); foreach (Curve curve in curves) { points.Add(curve.get_EndPoint(0)); points.Add(curve.get_EndPoint(1)); } } return points; }
/// <summary> /// get the vertexes of the bounding box which covers all the curtain cells /// </summary> /// <param name="cells"> /// the source curtain cells /// </param> /// <param name="minXYZ"> /// the result bounding point /// </param> /// <param name="maxXYZ"> /// the result bounding point /// </param> private void GetVertexesByCells(CurtainCellSet cells, ref Autodesk.Revit.DB.XYZ minXYZ, ref Autodesk.Revit.DB.XYZ maxXYZ) { if (null == cells || true == cells.IsEmpty) { return; } List<Autodesk.Revit.DB.XYZ> points = GetPoints(cells); GetVertexesByPoints(points, ref minXYZ, ref maxXYZ); }
/// <summary> /// get all of the 4 vertexes of the curtain grid /// </summary> /// <returns></returns> private bool GetCurtainGridVertexes() { // even in "ReloadGeometryData()" method, no need to reload the boundary information // (as the boundary of the curtain grid won't be changed in the sample) // just need to load it after the curtain wall been created if (null != m_GridVertexesXYZ && 0 < m_GridVertexesXYZ.Count) { return(true); } // the curtain grid is from "Curtain Wall: Curtain Wall 1" (by default, the "Curtain Wall 1" has no U/V grid lines) if (m_uGridLines.Count <= 0 || m_vGridLines.Count <= 0) { // special handling for "Curtain Wall: Curtain Wall 1" // as the "Curtain Wall: Curtain Wall 1" has no U/V grid lines, so we can't compute the boundary from the grid lines // as that kind of curtain wall contains only one curtain cell // so we compute the boundary from the data of the curtain cell // Obtain the geometry information of the curtain wall // also works with some curtain grids with only U grid lines or only V grid lines Transaction act = new Transaction(m_activeDocument, Guid.NewGuid().GetHashCode().ToString()); act.Start(); CurtainCellSet cells = m_activeGrid.Cells; act.Commit(); Autodesk.Revit.DB.XYZ minXYZ = new Autodesk.Revit.DB.XYZ(Double.MaxValue, Double.MaxValue, Double.MaxValue); Autodesk.Revit.DB.XYZ maxXYZ = new Autodesk.Revit.DB.XYZ(Double.MinValue, Double.MinValue, Double.MinValue); GetVertexesByCells(cells, ref minXYZ, ref maxXYZ); // move the U & V lines to the boundary of the curtain grid, and get their end points as the vertexes of the curtain grid m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(minXYZ.X, minXYZ.Y, minXYZ.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(maxXYZ.X, maxXYZ.Y, minXYZ.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(maxXYZ.X, maxXYZ.Y, maxXYZ.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(minXYZ.X, minXYZ.Y, maxXYZ.Z)); return(true); } else { // handling for the other kinds of curtain walls (contains U&V grid lines by default) CurtainGridLine uLine = m_uGridLines[0]; CurtainGridLine vLine = m_vGridLines[0]; List <Autodesk.Revit.DB.XYZ> points = new List <Autodesk.Revit.DB.XYZ>(); Autodesk.Revit.DB.XYZ uStartPoint = uLine.FullCurve.get_EndPoint(0); Autodesk.Revit.DB.XYZ uEndPoint = uLine.FullCurve.get_EndPoint(1); Autodesk.Revit.DB.XYZ vStartPoint = vLine.FullCurve.get_EndPoint(0); Autodesk.Revit.DB.XYZ vEndPoint = vLine.FullCurve.get_EndPoint(1); points.Add(uStartPoint); points.Add(uEndPoint); points.Add(vStartPoint); points.Add(vEndPoint); //move the U & V lines to the boundary of the curtain grid, and get their end points as the vertexes of the curtain grid m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(uStartPoint.X, uStartPoint.Y, vStartPoint.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(uEndPoint.X, uEndPoint.Y, vStartPoint.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(uEndPoint.X, uEndPoint.Y, vEndPoint.Z)); m_GridVertexesXYZ.Add(new Autodesk.Revit.DB.XYZ(uStartPoint.X, uStartPoint.Y, vEndPoint.Z)); return(true); } }