/// <summary> /// 修改指定名称状态 /// </summary> /// <param name="panel"></param> /// <param name="itemNames"></param> /// <param name="b"></param> internal static void SetItems(RibbonPanel panel, string[] itemNames, bool b) { var items = panel.GetItems(); var its = items.Where(c => itemNames.Contains(c.Name)).ToArray(); foreach (var item in its) { item.Enabled = b; } }
Stream(ArrayList data, RibbonPanel ribbonPanel) { data.Add(new Snoop.Data.ClassSeparator(typeof(RibbonPanel))); data.Add(new Snoop.Data.Bool("Enabled", ribbonPanel.Enabled)); data.Add(new Snoop.Data.Enumerable("Items", ribbonPanel.GetItems())); data.Add(new Snoop.Data.String("Name", ribbonPanel.Name)); data.Add(new Snoop.Data.String("Title", ribbonPanel.Title)); data.Add(new Snoop.Data.Bool("Visible", ribbonPanel.Visible)); }
/// <summary> /// 修改指定位置状态 /// </summary> /// <param name="panel"></param> /// <param name="itemIndices"></param> /// <param name="b"></param> internal static void SetItems(RibbonPanel panel, int[] itemIndices, bool b) { var items = panel.GetItems(); for (int i = 0; i < items.Count; i++) { if (Array.IndexOf(itemIndices, i) != -1) { items[i].Enabled = b; } } }
/// <summary> /// return the RibbonItem by the input name in a specific panel /// </summary> /// <param name="panelRibbon">RibbonPanel which contains the RibbonItem </param> /// <param name="itemName">name of RibbonItem</param> /// <return>RibbonItem whose name is same with input string</param> public RibbonItem GetRibbonItemByName(RibbonPanel panelRibbon, String itemName) { foreach (RibbonItem item in panelRibbon.GetItems()) { if (itemName == item.Name) { return(item); } } return(null); }
private static SplitButton FindSplitByName(RibbonPanel panel, string name) { foreach (RibbonItem item in panel.GetItems()) { if (item.ItemType == RibbonItemType.SplitButton) { SplitButton splitbt = item as SplitButton; if (splitbt.Name == name) { return(splitbt); } } } return(null); }
public Result OnStartup(UIControlledApplication application) { application.Idling += new EventHandler <IdlingEventArgs>(ShowCommand); _path = Uri.UnescapeDataString((new UriBuilder(Assembly.GetExecutingAssembly().CodeBase)).Path); _resorce = _path.Substring(0, _path.LastIndexOf("/d") + 1) + @"resorce/"; string tabName = "Walter"; application.CreateRibbonTab(tabName); RibbonPanel ribbonPanel = application.CreateRibbonPanel(tabName, "Tools"); InitRibbonButtons(ribbonPanel); var s = ribbonPanel.GetItems(); return(Result.Succeeded); }
private Dictionary <string, PulldownButton> GetDictionaryWithPulldownButtons() { IList <RibbonItem> itemsOnRibbon = _ribbonPanel.GetItems(); Dictionary <string, PulldownButton> pulldownButtons = new Dictionary <string, PulldownButton>(); foreach (var ribbonItem in itemsOnRibbon) { if (ribbonItem.ItemType == RibbonItemType.PulldownButton) { pulldownButtons[ribbonItem.Name] = (PulldownButton)ribbonItem; } } return(pulldownButtons); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; RibbonPanel inputpanel = null; PushButton toggle_Insulation = null; foreach (RibbonPanel panel in uiapp.GetRibbonPanels("Exp. Add-Ins")) { if (panel.Name == "Re-Elevate") { inputpanel = panel; } } foreach (RibbonItem item in inputpanel.GetItems()) { if (item.Name == "Toggle_Insulation") { toggle_Insulation = (PushButton)item; } } string s = toggle_Insulation.ItemText; toggle_Insulation.ItemText = s.Equals("Align to INS") ? "Align to MEP" : "Align to INS"; //find and switch button and data string IconsPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Icons\\"); string im_ins = IconsPath + "Button_Ins.png"; string im_nin = IconsPath + "Button_NoIns.png"; Uri uriImage = new Uri(im_nin); BitmapImage Image = new BitmapImage(uriImage); if (toggle_Insulation.ItemText == "Align to MEP") { uriImage = new Uri(im_nin); Image = new BitmapImage(uriImage); toggle_Insulation.Image = Image; } else { uriImage = new Uri(im_ins); Image = new BitmapImage(uriImage); toggle_Insulation.Image = Image; } return(Result.Succeeded); }
public static TI GetRibbonItem <TI>(this UIApplication uiApplication, string tabName, string panelName, string ribbonItemName) where TI : RibbonItem { RibbonPanel itemPanel = uiApplication.GetRibbonPanels(tabName).First(panel => panel.Name == panelName); if (itemPanel == null) { return(null); } var ritem = itemPanel.GetItems().First(item => item.Name == ribbonItemName); if (ritem == null) { return(null); } return((TI)ritem); }
//public void application_Sync(object sender, DocumentSynchronizingWithCentralEventArgs args) //{ // Document doc = args.Document; //progress.Report(doc); //} public void getdoc(object sender, ViewActivatedEventArgs args) { doc = args.Document; ComboBoxMemberData Range1 = new ComboBoxMemberData("0", "1/2\""); ComboBoxMemberData Range2 = new ComboBoxMemberData("1", "1\""); ComboBoxMemberData Range3 = new ComboBoxMemberData("2", "3\""); ComboBoxMemberData Range4 = new ComboBoxMemberData("3", "1' 0\""); ComboBoxMemberData Range5 = new ComboBoxMemberData("4", "3' 0\""); ComboBoxMemberData Range6 = new ComboBoxMemberData("5", "10' 0\""); if (doc.DisplayUnitSystem == DisplayUnit.IMPERIAL) { UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1/2\"", out StoreExp.vrOpt1); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1\"", out StoreExp.vrOpt2); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "3\"", out StoreExp.vrOpt3); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1'0\"", out StoreExp.vrOpt4); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "3'0\"", out StoreExp.vrOpt5); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "10'0\"", out StoreExp.vrOpt6); } else { UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "1 cm", out StoreExp.vrOpt1); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "2 cm", out StoreExp.vrOpt2); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "10 cm", out StoreExp.vrOpt3); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "30 cm", out StoreExp.vrOpt4); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "90 cm", out StoreExp.vrOpt5); UnitFormatUtils.TryParse(doc.GetUnits(), UnitType.UT_Length, "300 cm", out StoreExp.vrOpt6); Range1.Text = "1 cm"; Range2.Text = "2 cm"; Range3.Text = "10 cm"; Range4.Text = "30 cm"; Range5.Text = "90 cm"; Range6.Text = "300 cm"; } UiCtrApp.ViewActivated -= getdoc; foreach (RibbonItem item in panel_ViewSetup.GetItems()) { if (item.Name == "ShiftRange") { ComboBox ShiftRange_CB = (ComboBox)item; ShiftRange_CB.AddItem(Range1); ShiftRange_CB.AddItem(Range2); ShiftRange_CB.AddItem(Range3); ShiftRange_CB.AddItem(Range4); ShiftRange_CB.AddItem(Range5); ShiftRange_CB.AddItem(Range6); } } doc = null; }
public static PushButton GetButton(UIApplication uiapp, string panelname, string itemname) { RibbonPanel inputpanel = null; PushButton toggle_Insulation = null; foreach (RibbonPanel panel in uiapp.GetRibbonPanels("Exp. Add-Ins")) { if (panel.Name == panelname) { inputpanel = panel; } } foreach (RibbonItem item in inputpanel.GetItems()) { if (item.Name == itemname) { toggle_Insulation = (PushButton)item; } } return(toggle_Insulation); }
/// <summary> /// return the RibbonItem by the input name in a specific panel /// </summary> /// <param name="panelRibbon">RibbonPanel which contains the RibbonItem </param> /// <param name="itemName">name of RibbonItem</param> /// <return>RibbonItem whose name is same with input string</param> public RibbonItem GetRibbonItemByName(RibbonPanel panelRibbon, String itemName) { foreach (RibbonItem item in panelRibbon.GetItems()) { if (itemName == item.Name) { return item; } } return null; }
public Result OnStartup(UIControlledApplication a) { UiCtrApp = a; try { // Register event for Syncronization // a.ControlledApplication.DocumentSynchronizingWithCentral += new EventHandler // <Autodesk.Revit.DB.Events.DocumentSynchronizingWithCentralEventArgs>(application_Sync); UiCtrApp.ViewActivated += new EventHandler <Autodesk.Revit.UI.Events.ViewActivatedEventArgs>(getdoc); } catch (Exception) { return(Result.Failed); } a.CreateRibbonTab("Exp. Add-Ins"); RibbonPanel panel_Export = a.CreateRibbonPanel("Exp. Add-Ins", "Export"); panel_ViewSetup = a.CreateRibbonPanel("Exp. Add-Ins", "View Tools"); RibbonPanel panel_Reelevate = a.CreateRibbonPanel("Exp. Add-Ins", "Re-Elevate"); RibbonPanel panel_Annot = a.CreateRibbonPanel("Exp. Add-Ins", "Annotation"); RibbonPanel panel_Managers = a.CreateRibbonPanel("Exp. Add-Ins", "Managers"); RibbonPanel panel_Spec = a.CreateRibbonPanel("Exp. Add-Ins", "Specific"); RibbonPanel panel_Qt = a.CreateRibbonPanel("Exp. Add-Ins", "Quick Tools"); string thisAssemblyPath = Assembly.GetExecutingAssembly().Location; string root = thisAssemblyPath.Remove(thisAssemblyPath.Length - 11); PushButtonData button_DWGExport = new PushButtonData("Button_DWGExport", "Export DWG", root + "DWGExport.dll", "DWGExport.DWGExport"); PushButtonData button_NavisExport = new PushButtonData("button_NavisExport", "Export NWC", root + "DWGExport.dll", "NavisExport.NavisExport"); PushButtonData button_AllExport = new PushButtonData("Button_Navis_DWGExport", "Export All", root + "DWGExport.dll", "ExportAll.ExportAll"); PushButton button_RevPrint = panel_Export.AddItem(new PushButtonData("Button_RevPrint", "Print Revision", root + "DWGExport.dll", "PrintRevision.PrintRevision")) as PushButton; button_DWGExport.ToolTip = "Selected Views/Sheets will be exported to .DWG. Tip: use Manage Save/Load selection for sets."; button_NavisExport.ToolTip = "Views with 'Export' as Title on Sheet will be exported to .NWC"; button_AllExport.ToolTip = "Views with 'Export' as Title on Sheet will be exported to .DWG and .NWC"; button_RevPrint.ToolTip = "Select and Print a certain Revision using the current print settings."; PushButtonData button_ShiftViewRange_Top_Up = new PushButtonData("Button_ShiftViewRange_Top_Up", "T+", root + "SetViewRange.dll", "SetViewRange.Shift_TU"); PushButtonData button_ShiftViewRange_Top_Down = new PushButtonData("Button_ShiftViewRange_Top_Down", "T-", root + "SetViewRange.dll", "SetViewRange.Shift_TD"); PushButtonData button_ShiftViewRange_Bottom_Up = new PushButtonData("Button_ShiftViewRange_Bottom_Up", "B+", root + "SetViewRange.dll", "SetViewRange.Shift_BU"); PushButtonData button_ShiftViewRange_Bottom_Down = new PushButtonData("Button_ShiftViewRange_Bottom_Down", "B-", root + "SetViewRange.dll", "SetViewRange.Shift_BD"); PushButtonData button_SetViewRange = new PushButtonData("Button_SetViewRange", "Set View Range per 3D", root + "SetViewRange.dll", "SetViewRange.SetPer3D"); button_ShiftViewRange_Top_Up.ToolTip = "Shifts Top of View Range by set value - Up."; button_ShiftViewRange_Top_Down.ToolTip = "Shifts Top of View Range by set value - Down."; button_ShiftViewRange_Bottom_Up.ToolTip = "Shifts Bottom of View Range by set value - Up."; button_ShiftViewRange_Bottom_Down.ToolTip = "Shifts Bottom of View Range by set value - Down."; button_SetViewRange.ToolTip = "Sets View Range of active Plan View to Top and Bottom planes of the Section Box used on identically named 3d View."; PushButtonData button_TL = new PushButtonData("ToggleLink", "Toggle Links", root + "MultiDWG.dll", "MultiDWG.ToggleLink"); PushButtonData button_TPC = new PushButtonData("TogglePC", "Toggle PCs", root + "MultiDWG.dll", "MultiDWG.TogglePC"); button_TL.ToolTip = "Toggles visibility of all Links in the active view"; button_TPC.ToolTip = "Toggles visibility of all Point Clouds in the active view"; PushButton button_RehostElements = panel_Reelevate.AddItem(new PushButtonData("Button_RehostElements", "Rehost Elements", root + "Rehost Elements.dll", "RehostElements.RehostElements")) as PushButton; PushButtonData button_AlignToBottom = new PushButtonData("Button_AlignToBottom", "MEP to Bottom", root + "AlignToBottom.dll", "AlignToBottom.AlignToBottom"); PushButtonData button_AlignToTop = new PushButtonData("Button_AlignToTop", "MEP to Top", root + "AlignToBottom.dll", "AlignToBottom.AlignToTop"); button_RehostElements.ToolTip = "Sets the Reference Level of selected elements to the active Plan View's Associated Level"; button_AlignToBottom.ToolTip = "Aligns Bottom of MEP elements to the bottom of selected MEP element"; button_AlignToTop.ToolTip = "Aligns Top of MEP elements to the top of selected MEP element"; PushButtonData button_MultiDWG = new PushButtonData("Button_MultiDWG", "MultiDWG", root + "MultiDWG.dll", "MultiDWG.MultiDWG"); PushButtonData button_DuctSurfaceArea = new PushButtonData("Button_DSA", "Duct F. Unfolded", root + "MultiDWG.dll", "MultiDWG.DuctSurfaceArea"); PushButtonData button_ConduitAngle = new PushButtonData("Button_CA", "Conduit Angles", root + "MultiDWG.dll", "MultiDWG.ConduitAngle"); button_MultiDWG.ToolTip = "Specific: Loads all .DWG-s from selected folder. Sets LOD according to filename, temporarily hides medium and high LOD-s."; button_DuctSurfaceArea.ToolTip = "Specific: Inserts total surface area without connections into \"Duct Surface Area\" Project Parameter."; button_ConduitAngle.ToolTip = "Specific: Sums the angles of selected Conduit turns"; panel_Spec.AddStackedItems(button_MultiDWG, button_DuctSurfaceArea, button_ConduitAngle); PushButtonData toggle_Insulation = new PushButtonData("Toggle_Insulation", "Align to INS", root + "AlignToBottom.dll", "Toggle.Toggle"); toggle_Insulation.ToolTip = "Aligns to Insulation surfaces, when present"; PushButtonData button_Qv1 = new PushButtonData("Qv1", "1", root + "SetViewRange.dll", "QuickViews.QuickView1"); PushButtonData button_Qv2 = new PushButtonData("Qv2", "2", root + "SetViewRange.dll", "QuickViews.QuickView2"); PushButtonData button_Qv3 = new PushButtonData("Qv3", "3", root + "SetViewRange.dll", "QuickViews.QuickView3"); PushButtonData button_Qv4 = new PushButtonData("Qv4", "4", root + "SetViewRange.dll", "QuickViews.QuickView4"); PushButtonData button_Qv5 = new PushButtonData("Qv5", "5", root + "SetViewRange.dll", "QuickViews.QuickView5"); PushButtonData button_Qv6 = new PushButtonData("Qv6", "6", root + "SetViewRange.dll", "QuickViews.QuickView6"); button_Qv1.ToolTip = "Switch View to 'QuickView 1'"; button_Qv2.ToolTip = "Switch View to 'QuickView 2'"; button_Qv3.ToolTip = "Switch View to 'QuickView 3'"; button_Qv4.ToolTip = "Switch View to 'QuickView 4'"; button_Qv5.ToolTip = "Switch View to 'QuickView 5'"; button_Qv6.ToolTip = "Switch View to 'QuickView 6'"; panel_ViewSetup.AddStackedItems(button_Qv1, button_Qv2, button_Qv3); panel_ViewSetup.AddStackedItems(button_Qv4, button_Qv5, button_Qv6); PushButton button_SetupQV = panel_ViewSetup.AddItem(new PushButtonData("Button_SetupQV", "Options", root + "SetViewRange.dll", "QuickViews.QuickViews")) as PushButton; PushButtonData button_Dim2Grid = new PushButtonData("Dimtogrid", "RackDim", root + "AnnoTools.dll", "AnnoTools.RackDim"); PushButtonData button_Rack = new PushButtonData("Rack", "Rack", root + "AnnoTools.dll", "AnnoTools.Rack"); PushButtonData button_Lin = new PushButtonData("Lin", "Linear", root + "AnnoTools.dll", "AnnoTools.LinearAnnotation"); string versioned = "AnnoTools"; if (a.ControlledApplication.VersionName.Contains("2017")) { versioned = "Exp_apps_R17"; } PushButtonData button_MTag = new PushButtonData("MTag", "MultiTag", root + versioned + ".dll", versioned + ".MultiTag"); PushButtonData button_ManageRefs = new PushButtonData("Button_ManageRefs", "Mng. Ref.Planes", root + "MultiDWG.dll", "MultiDWG.ManageRefPlanes"); PushButtonData button_ManageRevs = new PushButtonData("Button_ManageRevs", "Mng. Revisions", root + "Revision_Editor.dll", "Revision_Editor.Revision_Editor"); button_SetupQV.ToolTip = "Set quick access to views and more."; button_Dim2Grid.ToolTip = "Create Dimension referring the selected element's centerlines and Grids."; button_Rack.ToolTip = "Create tag for Conduit Rack, listing conduits: left to right \\ top to bottom"; button_Lin.ToolTip = "Create Dimension for objects with more distance in-between"; button_MTag.ToolTip = "Create Tags by Category for multiple selected elements at once"; button_ManageRefs.ToolTip = "Create Reference Planes from at the origins of 3 selected items, or Delete Ref.Planes"; button_ManageRevs.ToolTip = "Manage Revisions"; TextBoxData leftSpaceData = new TextBoxData("A"); TextBoxData rightSpaceData = new TextBoxData("B"); TextBoxData firstYData = new TextBoxData("C"); TextBoxData stepYData = new TextBoxData("1"); TextBoxData splitPointData = new TextBoxData("2"); TextBoxData placementData = new TextBoxData("3"); panel_Annot.AddStackedItems(leftSpaceData, rightSpaceData, firstYData); panel_Annot.AddStackedItems(stepYData, splitPointData, placementData); foreach (RibbonItem item in panel_Annot.GetItems()) { SetTextBox(item, "A", ":A:", "Distance of TextBoxes on Left", 60); SetTextBox(item, "B", ":B:", "Distance of TextBoxes on Right", 60); SetTextBox(item, "C", ":C:", "Height offset of TextBoxes", 60); SetTextBox(item, "1", ":1:", "Gap between TextBoxes", 60); SetTextBox(item, "2", ":2:", "Controls directional switch, and linebreaks of TextBoxes", 60); SetTextBox(item, "3", ":3:", "Placement of annotation along the reference line", 60); } PulldownButtonData QtData = new PulldownButtonData("Quicktools", "QuickTools"); PulldownButton QtButtonGroup = panel_Qt.AddItem(QtData) as PulldownButton; PushButtonData qt1 = new PushButtonData("Filter Verticals", "Filter Vert", root + "MultiDWG.dll", "MultiDWG.FindVert"); PushButtonData qt2 = new PushButtonData("Filter Round Hosted", "Filter Round Hosted", root + "AnnoTools.dll", "AnnoTools.CheckTag"); PushButtonData qt3 = new PushButtonData("Align Identicals", "Align Identicals", root + "AnnoTools.dll", "AnnoTools.Cleansheet"); PushButtonData qt4 = new PushButtonData("Replace in Parameter", "Replace in Parameter", root + "MultiDWG.dll", "MultiDWG.ReplaceInParam"); PushButtonData qt5 = new PushButtonData("Duplicate Sheets", "Duplicate Sheets", root + "MultiDWG.dll", "MultiDWG.DuplicateSheets"); qt1.ToolTip = "Filters Vertical elements from selection " + Environment.NewLine + ":1: controls vertical sensitivity"; qt2.ToolTip = "Filter the selected tags that are hosted to Round duct " + Environment.NewLine + ":3: Type for 'Rectangular' filter"; qt3.ToolTip = "Merges selected tags with same content." + Environment.NewLine + ":A: and :B: controls sensitivity"; qt4.ToolTip = "Replaces text in parameter of selection." + Environment.NewLine + ":A: - Parameter name" + Environment.NewLine + ":B: - Original" + Environment.NewLine + ":C: - Replace"; qt5.ToolTip = "Duplicates the selected sheets." + Environment.NewLine + ":A: - Suffix - Sheet Number" + Environment.NewLine + ":B: - Suffix - Sheet Name" + Environment.NewLine + ":C: - Type for Dependent view duplicates"; string IconsPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Icons\\"); string[] files = Directory.GetFiles(IconsPath); string im_dwg = IconsPath + "Button_DWGExport.png"; string im_nwc = IconsPath + "Button_NavisExport.png"; string im_all = IconsPath + "Button_AllExport.png"; string im_reh = IconsPath + "Button_RehostElements.png"; string im_tup = IconsPath + "Button_T_UP.png"; string im_tdn = IconsPath + "Button_T_DN.png"; string im_bup = IconsPath + "Button_B_UP.png"; string im_bdn = IconsPath + "Button_B_DN.png"; string im_ins = IconsPath + "Button_Ins.png"; string im_pre = IconsPath + "Button_PrintRev.png"; string im_pre_sm = IconsPath + "Button_PrintRev_sm.png"; string im_rak = IconsPath + "Button_Rack.png"; string im_d2g_sm = IconsPath + "Button_Dim2Grid_sm.png"; string im_ref = IconsPath + "Button_Ref.png"; string im_lin_sm = IconsPath + "Button_Lin_sm.png"; string im_mtag = IconsPath + "Button_MTag.png"; string im_tl_sm = IconsPath + "Button_TL_sm.png"; string im_tpc_sm = IconsPath + "Button_TPC_sm.png"; string im_qt1 = IconsPath + "Button_qt1.png"; string im_qt2 = IconsPath + "Button_qt2.png"; string im_qt3 = IconsPath + "Button_qt3.png"; string im_qt4 = IconsPath + "Button_qt4.png"; string im_qt5 = IconsPath + "Button_qt5.png"; string im_rev = IconsPath + "Button_Rev.png"; button_DWGExport.Image = SetImage(im_dwg); button_NavisExport.Image = SetImage(im_nwc); button_AllExport.Image = SetImage(im_all); button_ShiftViewRange_Top_Up.Image = SetImage(im_tup); button_ShiftViewRange_Top_Down.Image = SetImage(im_tdn); button_ShiftViewRange_Bottom_Up.Image = SetImage(im_bup); button_ShiftViewRange_Bottom_Down.Image = SetImage(im_bdn); button_RehostElements.Image = SetImage(im_reh); button_RehostElements.LargeImage = SetImage(im_reh); toggle_Insulation.Image = SetImage(im_ins); button_RevPrint.LargeImage = SetImage(im_pre); button_RevPrint.Image = SetImage(im_pre_sm); button_Rack.Image = SetImage(im_rak); button_Dim2Grid.Image = SetImage(im_d2g_sm); button_Lin.Image = SetImage(im_lin_sm); button_MTag.LargeImage = SetImage(im_mtag); button_ManageRefs.LargeImage = SetImage(im_ref); button_ManageRefs.Image = SetImage(im_ref); button_ManageRevs.LargeImage = SetImage(im_rev); button_ManageRevs.Image = SetImage(im_rev); button_TL.Image = SetImage(im_tl_sm); button_TPC.Image = SetImage(im_tpc_sm); qt1.LargeImage = SetImage(im_qt1); qt2.LargeImage = SetImage(im_qt2); qt3.LargeImage = SetImage(im_qt3); qt4.LargeImage = SetImage(im_qt4); qt5.LargeImage = SetImage(im_qt5); QtButtonGroup.AddPushButton(qt1); QtButtonGroup.AddPushButton(qt2); QtButtonGroup.AddPushButton(qt3); QtButtonGroup.AddPushButton(qt4); QtButtonGroup.AddPushButton(qt5); ComboBoxData ShiftRange = new ComboBoxData("ShiftRange"); panel_ViewSetup.AddStackedItems(button_ShiftViewRange_Bottom_Up, button_ShiftViewRange_Bottom_Down); panel_ViewSetup.AddStackedItems(button_ShiftViewRange_Top_Up, button_ShiftViewRange_Top_Down); panel_ViewSetup.AddStackedItems(button_TL, button_TPC); panel_Export.AddStackedItems(button_DWGExport, button_NavisExport, button_AllExport); panel_ViewSetup.AddStackedItems(button_SetViewRange, ShiftRange); panel_Reelevate.AddStackedItems(button_AlignToTop, button_AlignToBottom, toggle_Insulation); panel_Managers.AddItem(button_ManageRefs); panel_Managers.AddItem(button_ManageRevs); panel_Annot.AddStackedItems(button_Dim2Grid, button_Lin, button_Rack); panel_Annot.AddItem(button_MTag); a.ApplicationClosing += a_ApplicationClosing; //Set Application to Idling a.Idling += a_Idling; return(Result.Succeeded); }
//private void //Stream(ArrayList data, RibbonItem ribMenuItem) //{ // data.Add(new Snoop.Data.ClassSeparator(typeof(RibbonItem))); // data.Add(new Snoop.Data.Enumerable("Items", ribMenuItem.Items)); // data.Add(new Snoop.Data.String("Item text", ribMenuItem.ItemText)); //} private void Stream(ArrayList data, RibbonPanel ribbonPanel) { data.Add(new Snoop.Data.ClassSeparator(typeof(RibbonPanel))); data.Add(new Snoop.Data.Bool("Enabled", ribbonPanel.Enabled)); data.Add(new Snoop.Data.Enumerable("Items", ribbonPanel.GetItems())); data.Add(new Snoop.Data.String("Name", ribbonPanel.Name)); data.Add(new Snoop.Data.String("Title", ribbonPanel.Title)); data.Add(new Snoop.Data.Bool("Visible", ribbonPanel.Visible)); }
public static void GetMenuValues(UIApplication uiapp) { double scale = uiapp.ActiveUIDocument.ActiveView.Scale; Store.scaleMod = 96 / scale; RibbonPanel inputpanel = null; foreach (RibbonPanel panel in uiapp.GetRibbonPanels("Exp. Add-Ins")) { if (panel.Name == "Annotation") { inputpanel = panel; } } foreach (RibbonItem item in inputpanel.GetItems()) { if (item.Name == "A") { Store.left_ib = (TextBox)item; } else if (item.Name == "B") { Store.right_ib = (TextBox)item; } else if (item.Name == "C") { Store.firsty_ib = (TextBox)item; } else if (item.Name == "1") { Store.stepy_ib = (TextBox)item; } else if (item.Name == "2") { Store.split_ib = (TextBox)item; } else if (item.Name == "3") { Store.place_ib = (TextBox)item; } } Double.TryParse(Store.left_ib.Value as string, out Store.mod_left); Double.TryParse(Store.right_ib.Value as string, out Store.mod_right); Double.TryParse(Store.firsty_ib.Value as string, out Store.mod_firsty); Double.TryParse(Store.stepy_ib.Value as string, out Store.mod_stepy); int.TryParse(Store.split_ib.Value as string, out Store.mod_split); Double.TryParse(Store.place_ib.Value as string, out Store.mod_place); double mod = 1 / Store.scaleMod; if (Store.mod_left == 0) { Store.mod_left = mod; } else { Store.mod_left /= Store.scaleMod; } if (Store.mod_right == 0) { Store.mod_right = mod; } else { Store.mod_right /= Store.scaleMod; } if (Store.mod_firsty == 0) { Store.mod_firsty = mod; } else { Store.mod_firsty /= Store.scaleMod; } if (Store.mod_stepy == 0) { Store.mod_stepy = mod; } else { Store.mod_stepy /= Store.scaleMod; } }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; if (!(doc.ActiveView is ViewPlan viewPlan)) { TaskDialog.Show("Please select Plan view", "Select Plan view to change it's View Range"); return(Result.Succeeded); } PlanViewRange viewRange = viewPlan.GetViewRange(); double CCut = viewRange.GetOffset(PlanViewPlane.CutPlane); double CTop = viewRange.GetOffset(PlanViewPlane.TopClipPlane); RibbonPanel inputpanel = null; ComboBox inputbox = null; foreach (RibbonPanel panel in uiapp.GetRibbonPanels("Exp. Add-Ins")) { if (panel.Name == "View Tools") { inputpanel = panel; } } foreach (RibbonItem item in inputpanel.GetItems()) { if (item.Name == "ShiftRange") { inputbox = (ComboBox)item; } } List <Double> vrOpts = new List <Double> { StoreExp.vrOpt1, StoreExp.vrOpt2, StoreExp.vrOpt3, StoreExp.vrOpt4, StoreExp.vrOpt5, StoreExp.vrOpt6 }; double mod = vrOpts[Int32.Parse(inputbox.Current.Name)]; if (viewPlan.ViewType != ViewType.CeilingPlan) { viewRange.SetOffset(PlanViewPlane.CutPlane, CCut + mod); viewRange.SetOffset(PlanViewPlane.TopClipPlane, CCut + mod); } if (viewPlan.ViewType == ViewType.CeilingPlan) { viewRange.SetOffset(PlanViewPlane.TopClipPlane, CTop + mod); viewRange.SetOffset(PlanViewPlane.ViewDepthPlane, CTop + mod); } using (Transaction t = new Transaction(doc, "Set View Range")) { try { t.Start(); viewPlan.SetViewRange(viewRange); t.Commit(); } catch { TaskDialog.Show("Error", "Cannot shift ViewRange this way."); } } return(Result.Succeeded); }
/// <summary> /// return the RibbonItem by the input name in a specific panel /// </summary> /// <param name="panelRibbon">RibbonPanel which contains the RibbonItem </param> /// <param name="itemName">name of RibbonItem</param> /// <return>RibbonItem whose name is same with input string</return> public static RibbonItem GetRibbonItemByName(RibbonPanel panelRibbon, string itemName) { return(panelRibbon.GetItems().FirstOrDefault(c => c.Name == itemName)); }