Many users create scripts. Sometimes it’s comfortable to have them in form of a plug-in with a direct button in your menu.

For this case we have an empty demo project:
Download C Sharp Code

There are two classes in this example code one with the plugin:

  • ClassPCBIConnection.cs includes all the details PCB-Investigator needs to create and react to the button.
  • CalssScript.cs has an execute method like all scripts, just put your code and variables in it to change the PCB-Investigator button.

After rebuilding your class library it is necessary to copy the dll to your plug-in directory. You find the directory by opening PCB-Investigator, goto options -> Plug-ins.
(see image at the end)

class ClassScript
  {
    internal string NameOfPlugIn = "Unique Name of Script PlugIn or GUID";
    internal string TextOnButton = "Start Demo";
 
    public void Excecute(IPCBIWindow parent)
    {
      parent.UIAction.Execute(ID_ActionItem.ID_JOB_LIBRARY);
 
      parent.UpdateView();
    }
  }
 
[Plugin("RibbonDemo", "Demo", "Demo to show how to add to PCB-Investigator Ribbon menu.", "1.0.0.0")]
  public class ClassPCBIConnection: IPluginRibbonCommand
  {
 
    #region IPluginToolStrip Members
    //On which position should the toolbar dock.
    private ContainerPosition position = ContainerPosition.Left;
    public ContainerPosition Position
    {
      get
      {
        return position;
      }
      set
      {
        position = value;
      }
    }
    #endregion
 
    #region IPlugin Members
    //interface information
    private bool pluginEnabled;
    public bool PluginEnabled
    {
      get
      {
        return pluginEnabled;
      }
      set
      {
        pluginEnabled = value;
      }
    }
    private string assembly;
    public string Assembly
    {
      get
      {
        return assembly;
      }
      set
      {
        assembly = value;
      }
    }
    private string path;
    public string Path
    {
      get
      {
        return path;
      }
      set
      {
        path = Path;
      }
    }
    private Type type;
    public Type Type
    {
      get
      {
        return type;
      }
      set
      {
        type = value;
      }
    }
    IPCBIWindow parent;
    public IPCBIWindow Parent
    {
      get
      {
        return parent;
      }
      set
      {
        parent = value;
      }
    }
    private PluginDestinationWindow pluginDestination = PluginDestinationWindow.MainWindow;
    public PluginDestinationWindow PluginDestination
    {
      get
      {
        return pluginDestination;
      }
      set
      {
        pluginDestination = value;
      }
    }
    public bool IsActionAllowed(ID_ActionItem action)
    {
      return false;
    }
    public void InitEvents(IPCBIWindow Parent)
    {
    }
    #endregion
 
    #region ribbon
    int registerEntryPCBI = -1;
    
    public void OnCommandExecute(int cmdID)
    {
      if (cmdID == registerEntryPCBI)
      {
        try
        {
          if(UsedScriptToStart!=null) UsedScriptToStart.Excecute(parent);
        }
        catch (Exception exceptionInScript)
        {
          //do error handling
 
        }
      }
    }
 
    public void RegisterCommand()
    {
      UsedScriptToStart = new ClassScript();
 
      registerEntryPCBI = Parent.UIAction.RegisterID(new IRegisterItem()
      {
        Category = "Demo",
        EnableOn = Availability.Always,
        GUID = "MustBeUnique!_" + UsedScriptToStart.NameOfPlugIn,
        RegisterType = RegisterItemType.BUTTON,
        Text = UsedScriptToStart.TextOnButton
      });
 
 
    }
 
    #endregion
 
    ClassScript UsedScriptToStart = null;
  }