How to load a Gerber layer

As easy example to use PCB-Investigator as library here the code to load a gerber layer and count elements on it. Its important to add the reference of PCB-Investigator first and add using PCBI.Automation.

Here is the example code in C Sharp and VB:

/// <summary>
    /// Create an overview how much elements on one gerberlayer.
    /// </summary>
    private static void CreateGerberReport()
      //create a window to handle your actions
      IPCBIWindow mainWindowPCBI = IAutomation.CreateNewPCBIWindow(false);
      //create a directory for ODB++ structure with one step names "pcb"
      string jobPath = mainWindowPCBI.CreateNewJobDirectory(@"C:\tests\FirstTestJob", "FirstTestJob", "pcb");
      //after creating the directory we have to load it
      IStep firstStep = mainWindowPCBI.GetStep("pcb");
      //show a dialog to select the first layer from an gerber file
      OpenFileDialog openDLG = new OpenFileDialog();
      openDLG.Title = "Select gerber file for demo application";
      if (openDLG.ShowDialog() != System.Windows.Forms.DialogResult.OK)
      //we load the gerberdata in one layer and remember the layername
      string gerberLayerName = firstStep.AddGerberLayer(openDLG.FileName, false);
      //we need the ILayer object for handling data of the gerberfile
      ILayer GerberLayer = firstStep.GetLayer(gerberLayerName);
      //now we make an report of all element types
      int counterPads = 0;
      int counterLines = 0;
      int counterArcs = 0;
      int counterOthers = 0;
      foreach (IObject ObjOnGerber in GerberLayer.GetAllLayerObjects())
        if (ObjOnGerber.Type == IObjectType.Pad)
        else if (ObjOnGerber.Type == IObjectType.Line)
        else if (ObjOnGerber.Type == IObjectType.Arc)
      Console.WriteLine("Report Gerber File " + gerberLayerName);
      Console.WriteLine("Pads: " + counterPads.ToString());
      Console.WriteLine("Lines: " + counterLines.ToString());
      Console.WriteLine("Arcs: " + counterArcs.ToString());
      Console.WriteLine("Others: " + counterOthers.ToString());