//获取轴号信息 public CalcGridInfoResult GetGridNumberShowInfo(bool bIdling, DllImportManeger.Rect rcMDIClientWin, ref System.Drawing.Point ptForm, ref Size sizeForm) { if (this.m_uiDoc == null) { return(CalcGridInfoResult.eError); } if (this.m_uiView == null) { IList <UIView> openUIViews = this.m_uiDoc.GetOpenUIViews(); foreach (UIView uiview in openUIViews) { if (uiview.ViewId == this.m_uiDoc.ActiveView.Id) { this.m_uiView = uiview; break; } } } if (this.m_uiView == null) { return(CalcGridInfoResult.eError); } this.GetAllRevitLinkInstancesInDoc(); this.m_lstViewOutLineInfo.Clear(); this.m_lstDrawElems.Clear(); this.m_lstGridNumShowInfo.Clear(); CalcGridInfoResult currentViewOutLine = this.GetCurrentViewOutLine(bIdling, rcMDIClientWin, ref sizeForm, ref ptForm); if (currentViewOutLine != CalcGridInfoResult.eSucceded) { return(currentViewOutLine); } this.GetAllGridInfo(); this.GetAllMultiSegmentGridInfo(); this.GetAllLevelInfo(); this.GetAllLevelInfoInLinkDoc(); if (this.m_lstDrawElems.Count <= 0) { return(CalcGridInfoResult.eError); } this.GetIntersectPtAndDirection(); if (this.m_lstGridNumShowInfo.Count <= 0) { return(CalcGridInfoResult.eError); } return(CalcGridInfoResult.eSucceded); }
public static extern int GetClientRect(IntPtr hWnd, out DllImportManeger.Rect lpRect);
//获取当前视图的外部线 private CalcGridInfoResult GetCurrentViewOutLine(bool bIdling, DllImportManeger.Rect rcMDIClientWin, ref Size szForm, ref System.Drawing.Point ptForm) { int m_left = 0; int m_right = 0; int m_top = 0; int m_bottom = 0; GetRevitWndRectangle(this.m_uiView, ref m_left, ref m_top, ref m_right, ref m_bottom); if (IsEqual((double)m_left, (double)m_right) || IsEqual((double)m_top, (double)m_bottom)) { return(CalcGridInfoResult.eMin); } if (bIdling && IsEqual((double)m_left, (double)this.m_nLeft) && IsEqual((double)m_top, (double)this.m_nTop) && IsEqual((double)m_right, (double)this.m_nRight) && IsEqual((double)m_bottom, (double)this.m_nBottom)) { return(CalcGridInfoResult.eIdling); } this.m_nLeft = m_left; this.m_nRight = m_right; this.m_nTop = m_top; this.m_nBottom = m_bottom; if (GreaterThan((double)rcMDIClientWin.left, (double)m_left)) { m_left = rcMDIClientWin.left; } if (LessThan((double)rcMDIClientWin.right, (double)m_right)) { m_right = rcMDIClientWin.right; } if (GreaterThan((double)rcMDIClientWin.top, (double)m_top)) { m_top = rcMDIClientWin.top; } if (LessThan((double)rcMDIClientWin.bottom, (double)m_bottom)) { m_bottom = rcMDIClientWin.bottom; } XYZ xyz = new XYZ((double)m_left, (double)m_bottom, 0.0); XYZ xyz2 = new XYZ((double)m_left, (double)m_top, 0.0); XYZ xyz3 = new XYZ((double)m_right, (double)m_top, 0.0); XYZ xyz4 = new XYZ((double)m_right, (double)m_bottom, 0.0); szForm.Width = m_right - m_left; szForm.Height = m_bottom - m_top; ptForm.X = m_left; ptForm.Y = m_top; Line lnViewOutline = Line.CreateBound(xyz4, xyz); ViewOutLineInfo item = new ViewOutLineInfo(lnViewOutline, OutLineSide.eBottom); this.m_lstViewOutLineInfo.Add(item); Line lnViewOutline2 = Line.CreateBound(xyz, xyz2); ViewOutLineInfo item2 = new ViewOutLineInfo(lnViewOutline2, OutLineSide.eLeft); this.m_lstViewOutLineInfo.Add(item2); Line lnViewOutline3 = Line.CreateBound(xyz2, xyz3); ViewOutLineInfo item3 = new ViewOutLineInfo(lnViewOutline3, OutLineSide.eUp); this.m_lstViewOutLineInfo.Add(item3); Line lnViewOutline4 = Line.CreateBound(xyz3, xyz4); ViewOutLineInfo item4 = new ViewOutLineInfo(lnViewOutline4, OutLineSide.eRight); this.m_lstViewOutLineInfo.Add(item4); return(CalcGridInfoResult.eSucceded); }