/// <summary> /// Called to execute an API command and update the UI after the command is finished. /// </summary> public void Execute(UIApplication uiApp) { UIDocument uiDoc = uiApp.ActiveUIDocument; try { switch (RequestId) { case ModelessCommandId.DrawFace: // 绘制面层 FaceDrawer fd = new FaceDrawer(); fd.DrawFaces(uiDoc, DrawFaceOptions); break; case ModelessCommandId.Filter: FaceFilter ff2 = new FaceFilter(uiDoc.Document); var faces1 = ff2.FilterSelected(DrawFaceOptions); // uiDoc.Selection.SetElementIds(faces1); break; case ModelessCommandId.SelectAll: FaceFilter ff3 = new FaceFilter(uiDoc.Document); var faces2 = ff3.GetAllInSelected(); // uiDoc.Selection.SetElementIds(faces2.Select(r => r.FaceElement.Id).ToList());; break; } } catch (Exception ex) { DebugUtils.ShowDebugCatch(ex, RequestId.ToString(), "面层绘制或过滤"); } finally { _mainPanel.WakeUp(); } }
/// <summary> /// 构造函数 /// </summary> private MpFaceOptions() { InitializeComponent(); // m_handler = new ExEventHandler(this); m_exEvent = ExternalEvent.Create(m_handler); // 面层在Revit中的类别信息 var itemSource = new FaceCategoryMapping[] { new FaceCategoryMapping("墙", FaceFilter.CategoryIds[0]), new FaceCategoryMapping("柱", FaceFilter.CategoryIds[1]), new FaceCategoryMapping("楼板", FaceFilter.CategoryIds[2]), new FaceCategoryMapping("结构框架", FaceFilter.CategoryIds[3]), new FaceCategoryMapping("屋顶", FaceFilter.CategoryIds[4]), new FaceCategoryMapping("天花板", FaceFilter.CategoryIds[5]), }; ComboxCategory.ItemsSource = itemSource; ComboxCategory.DisplayMemberPath = "Text"; ComboxCategory.SelectedValuePath = "CategoryId"; ComboxCategory.SelectedIndex = 0; // 面层的类型 FaceFilter ff = new FaceFilter(_uiApp.ActiveUIDocument.Document); IList <string> types = ff.GetFaceTypes(ff.GetAllInDoc()); foreach (string t in types) { ComboxType.Items.Add(t); } ComboxType.SelectedIndex = 0; // Revit主窗口的句柄 rvtHwnd = Process.GetCurrentProcess().MainWindowHandle; // 当 Revit中有其他的弹出窗口时,MainWindowHandle属性所指的可能就不是Revit程序的那个大窗口了。 }