public static void CustomizeUI() { if (_customized) { return; } _customized = true; if (Instances.DocumentEditor.Controls[4] is Grasshopper.GUI.GH_MenuStrip menuStrip) { var items = menuStrip.Items.Find("mnuSpecialFolders", true); if (items.Length != 0 && items[0] is ToolStripMenuItem specFold) { var samplesItem = new ToolStripMenuItem("Grasshopper-BricsCAD Connection"); samplesItem.Image = specFold.DropDownItems[0].Image; samplesItem.Click += (s, e) => { try { string directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); System.Diagnostics.Process.Start(@Path.Combine(directory, "Samples")); } catch (System.Exception) { } }; specFold.DropDownItems.Add(samplesItem); } } if (Instances.DocumentEditor.Controls[0].Controls[1] is ToolStrip toolbar) { var linkButton = new ToolStripButton(Properties.Resources.link) { ToolTipText = "Link with current BricsCAD document" }; linkButton.Click += (s, e) => { PlugIn.RelinkToDoc(Bricscad.ApplicationServices.Application.DocumentManager.MdiActiveDocument); }; toolbar.Items.Add(linkButton); var bakeSelectedButton = new ToolStripButton(Properties.Resources.bake) { ToolTipText = "Bakes the geometry from the selected Bake Geometry and Building Element components" }; bakeSelectedButton.Click += (s, e) => { BakeComponent.BakeSelectedComponents(); }; toolbar.Items.Add(bakeSelectedButton); } }
public static void StartGrasshopper() { PlugIn.LoadGrasshopperComponents(); var ghDocEditor = Grasshopper.Instances.DocumentEditor; if (ghDocEditor == null || !ghDocEditor.Visible) { if (System.Convert.ToInt16(Application.GetSystemVariable("DWGTITLED")) == 0) { System.Windows.Forms.MessageBox.Show("Bricscad drawing must be saved before using Grasshopper"); return; } } Rhino.RhinoApp.RunScript("!_-Grasshopper _W _T ENTER", false); if (Grasshopper.Instances.DocumentEditor.Visible) { PlugIn.RelinkToDoc(Application.DocumentManager.MdiActiveDocument); } GhUI.CustomizeUI(); }