/// <summary> /// 选择点,带预览,空时返回null /// </summary> /// <param name="uiApp"></param> /// <param name="startPoint"></param> /// <returns></returns> public XYZ PickPointWithLinePreview(UIApplication uiApp, XYZ startPoint) { XYZ result = null; Document doc = uiApp.ActiveUIDocument.Document; PickObjectsMouseHook mouseHook = null; mouseHook = InitMouseHook(); System.Windows.Forms.Timer timer = null; var view = new DrawAreaView(uiApp); view.Show(); view.StartPoint = new System.Windows.Point(startPoint.X, startPoint.Y); //开启定时器 实时绘图 timer = new System.Windows.Forms.Timer(); timer.Interval = 6; timer.Tick += (sender, e) => { view.PreviewLine(System.Windows.Forms.Control.MousePosition); }; timer.Start(); //选点 try { result = uiApp.ActiveUIDocument.Selection.PickPoint("PM-预览绘线中,鼠标左键确定,右键取消");//Autodesk.Revit.UI.Selection.ObjectSnapTypes.Endpoints, } catch { mouseHook.UninstallHook(); } timer.Stop(); view.Close(); mouseHook.Dispose(); mouseHook = null; return(result); }
protected override bool DoUI() { Form = new ListForm(this.m_app.ActiveUIDocument); PickObjectsMouseHook mouseHook = new PickObjectsMouseHook(); DialogResult result = DialogResult.Retry; while ((result = Form.ShowDialog(new RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry) { switch (Form.ShowDialogType) { case ShowDialogType.AddElements_ForDetail: case ShowDialogType.DeleleElements_ForDetail: switch (Form.SubFormType) { case SubFormType.Subsidence: try { mouseHook.InstallHook(); Form.SubFormForSubsidence.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件") .Select(p => m_doc.GetElement(p.ElementId).Id).ToList(); mouseHook.UninstallHook(); } catch { mouseHook.UninstallHook(); } Form.SubFormForSubsidence.FinishElementSelection(); break; case SubFormType.SkewBack: try { mouseHook.InstallHook(); Form.SubFormForSkewBack.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件") .Select(p => m_doc.GetElement(p.ElementId).Id).ToList(); mouseHook.UninstallHook(); } catch { mouseHook.UninstallHook(); } Form.SubFormForSkewBack.FinishElementSelection(); break; } break; case ShowDialogType.ViewElementsBySelectedNodes: case ShowDialogType.ViewElementsByAllNodes: case ShowDialogType.ViewCurrentMaxByRed: case ShowDialogType.ViewCurrentMaxByAll: case ShowDialogType.ViewTotalMaxByRed: case ShowDialogType.ViewTotalMaxByAll: case ShowDialogType.ViewCloseWarn: case ShowDialogType.ViewOverWarn: mouseHook.InstallHook(); m_uiDoc.Selection.PickObjects(ObjectType.Element, ""); mouseHook.UninstallHook(); break; } } return(true); }
protected override bool DoUI() { Form = new EarthworkBlockingForm(this.m_app); PickObjectsMouseHook mouseHook = new PickObjectsMouseHook(); DialogResult result = DialogResult.Retry; while ((result = Form.ShowDialog(new RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry) { if (result == DialogResult.Cancel) { return(false); } if (result == DialogResult.OK) { return(true); } if (Form.ShowDialogType == ShowDialogType.AddElements || Form.ShowDialogType == ShowDialogType.DeleleElements) { try { mouseHook.InstallHook(); Form.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件") .Select(p => m_doc.GetElement(p.ElementId).Id).ToList(); mouseHook.UninstallHook(); } catch { mouseHook.UninstallHook(); } Form.FinishElementSelection(); } if (Form.ShowDialogType == ShowDialogType.ViewGT6 || Form.ShowDialogType == ShowDialogType.ViewCompletion) { try { mouseHook.InstallHook(); m_uiDoc.Selection.PickObjects(ObjectType.Element, ""); mouseHook.UninstallHook(); } catch { mouseHook.UninstallHook(); } } } return(true); #region 非模态 //try //{ // if (ConfigPathManager.IniProjectDB(this.m_doc)) // { // Form = new EarthworkBlockingForm(this.m_app); // Form.ShowDialog(); // return true; // } // else // return false; //} //catch(Exception ex) //{ // TaskDialog.Show("错误", ex.Message); // return false; //} #endregion }