Automatically add buttons to the toolbar when GHA is loaded?

How to automatically add buttons to the toolbar when gha is loaded?
I need to add two buttons to the toolbar. How should I write them in the gha project?

This is a button added after GH is loaded, and it needs a GH_Commonent to be inserted into the current GHDocument. How to add it to the GHA project? Is it automatically added to the toolbar after loading the GHA file?

I have the same question?

Hello guys,

I went over this wire and this one:
Adding a button to Canvas toolbar? - Grasshopper Developer - McNeel Forum

Adding buttons to the canvas is what interested me as well. Putting together my “coding skill”, both wires and code from this:

rhino.inside-bricscad/GhUI.cs at master · Bricsys/rhino.inside-bricscad · GitHub

I can automatically add a button to the canvas as the Grasshopper is loaded.

I use Visual Studio to create my plugin. There is class which inherits from GH_AssemblyPrioroty (normally used for checking valid license)


This class has PriorityLoad() method which is called before plugin is loaded.

Code looks like this:

   public override GH_LoadingInstruction PriorityLoad()
        string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
        if (LicensedUsers.ContainsKey(userName))
            //Adding event, when Canvas is Created (this must be done with Canvas not DocumentEditor (otherwise DocumentEditor is null). )
            Instances.CanvasCreated += Instances_CanvasCreated;
            return (GH_LoadingInstruction.Proceed);
            return (GH_LoadingInstruction.Abort);
    private void Instances_CanvasCreated(GH_Canvas canvas)
        //Copied from rhino.inside-bricscad plugin
        Instances.CanvasCreated -= Instances_CanvasCreated;
        GH_DocumentEditor editor = Instances.DocumentEditor;
        //Check if DocumentEditor was instantiated
        if (editor == null)


        //Finally buttons is added to the Controls
        var toolbar = Grasshopper.Instances.DocumentEditor.Controls[0].Controls[1] as ToolStrip;
        var button = new System.Windows.Forms.ToolStripButton("Hi from Ondřej");

And result like this:

Hope it helps.



Hi, can I ask you a question? What are LicensedUsers? Why can’t I write this me !!,thank you very much.

It is my own Dictionary with licenses. You should modify that part or delete If condition.