예제 #1
0
 // 获取插入点和方向
 private void GetIntersectPtAndDirection()
 {
     foreach (OutViewInfo viewOutLineInfo in m_OutViewInfos)
     {
         foreach (DrawElement drawElement in m_DrawElems)
         {
             Curve curve = null;
             if (drawElement.DrawElemType == ElemType._Grid ||
                 drawElement.DrawElemType == ElemType._MultiSegGrid)
             {
                 Grid grid = drawElement.DrawElem as Grid;
                 if (grid == null ||
                     (drawElement.DrawElemType == ElemType._MultiSegGrid &&
                      (m_doc.ActiveView.ViewType == ViewType.Section ||
                       m_doc.ActiveView.ViewType == ViewType.Elevation)))
                 {
                     continue;
                 }
                 curve = GetGridCurve(m_doc.ActiveView, grid);
             }
             else if (drawElement.DrawElemType == ElemType._Level)
             {
                 Level level = drawElement.DrawElem as Level;
                 if (level == null)
                 {
                     continue;
                 }
                 curve = GetLevelCurve(m_doc.ActiveView, level);
             }
             if (!(curve == null))
             {
                 Curve curve2D = CurveToZero(curve);
                 //求边界线和轴网/标高的交点
                 IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
                 SetComparisonResult     setComparisonResult     = viewOutLineInfo.OutViewLine.Intersect(curve2D, out intersectionResultArray);
                 if (setComparisonResult == SetComparisonResult.Overlap &&
                     intersectionResultArray != null &&
                     intersectionResultArray.Size > 0)
                 {
                     for (int i = 0; i < intersectionResultArray.Size; i++)
                     {
                         GridNumShowInfo gridNumShowInfo = new GridNumShowInfo();
                         gridNumShowInfo.IntersectPoint = intersectionResultArray.get_Item(i).XYZPoint;
                         gridNumShowInfo.OutlineSide    = viewOutLineInfo.OutViewSide;
                         gridNumShowInfo.ElemText       = drawElement.DrawElem.Name;
                         gridNumShowInfo.ElemClass      = drawElement.DrawElemType;
                         m_GridNumShowInfos.Add(gridNumShowInfo);
                     }
                 }
             }
         }
     }
 }
 // 获取插入点和方向
 private void GetIntersectPtAndDirection()
 {
     foreach (ViewOutLineInfo viewOutLineInfo in this.m_lstViewOutLineInfo)
     {
         foreach (DrawElement drawElement in this.m_lstDrawElems)
         {
             Curve curve = null;
             if (drawElement.DrawElemType == ElemType.eGrid || drawElement.DrawElemType == ElemType.eMultiSegGrid)
             {
                 Grid grid = drawElement.DrawElem as Grid;
                 if (grid == null || (drawElement.DrawElemType == ElemType.eMultiSegGrid && (this.m_doc.ActiveView.ViewType == ViewType.Section || this.m_doc.ActiveView.ViewType == ViewType.Elevation)))
                 {
                     continue;
                 }
                 curve = GetGridCurve(this.m_doc.ActiveView, grid);
             }
             else if (drawElement.DrawElemType == ElemType.eLevel)
             {
                 Level level = drawElement.DrawElem as Level;
                 if (level == null)
                 {
                     continue;
                 }
                 curve = GetLevelCurve(this.m_doc.ActiveView, level);
             }
             if (!(curve == null))
             {
                 Curve curve2;
                 if (curve is Arc)
                 {
                     System.Drawing.Point point  = this.Revit2Screen(curve.GetEndPoint(0));
                     System.Drawing.Point point2 = this.Revit2Screen(curve.GetEndPoint(1));
                     System.Drawing.Point point3 = this.Revit2Screen(curve.Evaluate(0.5, true));
                     XYZ xyz  = new XYZ((double)point.X, (double)point.Y, 0.0);
                     XYZ xyz2 = new XYZ((double)point2.X, (double)point2.Y, 0.0);
                     XYZ xyz3 = new XYZ((double)point3.X, (double)point3.Y, 0.0);
                     curve2 = Arc.Create(xyz, xyz2, xyz3);
                 }
                 else
                 {
                     System.Drawing.Point point4 = this.Revit2Screen(curve.GetEndPoint(0));
                     System.Drawing.Point point5 = this.Revit2Screen(curve.GetEndPoint(1));
                     XYZ xyz4 = new XYZ((double)point4.X, (double)point4.Y, 0.0);
                     XYZ xyz5 = new XYZ((double)point5.X, (double)point5.Y, 0.0);
                     curve2 = Line.CreateBound(xyz4, xyz5);
                 }
                 IntersectionResultArray intersectionResultArray = new IntersectionResultArray();
                 SetComparisonResult     setComparisonResult     = viewOutLineInfo.ViewOutLine.Intersect(curve2, out intersectionResultArray);
                 if (setComparisonResult == SetComparisonResult.Overlap && intersectionResultArray != null && intersectionResultArray.Size > 0)
                 {
                     for (int i = 0; i < intersectionResultArray.Size; i++)
                     {
                         GridNumShowInfo gridNumShowInfo = new GridNumShowInfo();
                         gridNumShowInfo.IntersectPoint = intersectionResultArray.get_Item(i).XYZPoint;
                         gridNumShowInfo.OutlineSide    = viewOutLineInfo.OutlineSide;
                         gridNumShowInfo.ElemText       = drawElement.DrawElem.Name;
                         gridNumShowInfo.ElemClass      = drawElement.DrawElemType;
                         this.m_lstGridNumShowInfo.Add(gridNumShowInfo);
                     }
                 }
             }
         }
     }
 }