Here is the example code in C# and VB:

/// <summary>
    /// Load all GerberFiles, check all items on the gerberlayers and return the smallest height/widht.
    /// </summary>
    /// <param name="FileNames">full pathes of gerberfiles</param>
    /// <param name="parent">IPCBIWindow with loaded job!</param>
    /// <param name="smallestDiameter">The smallest diameter of all items</param>
    /// <returns>The smalles width and smalles height</returns>
    private System.Drawing.SizeF LoadGerberFilesAndGetSmallestObjectsSize(List<string> FileNames, IPCBIWindow parent, out double smallestDiameter)
    {
      System.Drawing.SizeF retSize = new System.Drawing.SizeF(float.MaxValue, float.MaxValue);
      IStep step = parent.GetCurrentStep();
      smallestDiameter = double.MaxValue;
      if (step == null) return retSize; //works only with loaded job!
 
      foreach (string filename in FileNames)
      {
        if (!File.Exists(filename)) continue;
 
        //add the layer and override existing layer with same name
        string newGerberName = step.AddGerberLayer(filename, true);
 
        ILayer layer = step.GetLayer(newGerberName);
        if (layer == null) continue; //maybe it was no gerber/excellon layer
 
        if (layer is IODBLayer) //gerber layers always IODBLayers
        {
          IODBLayer gerberLayer = (IODBLayer)layer;
 
          foreach (IObject gerberItem in gerberLayer.GetAllLayerObjects())
          {
            System.Drawing.RectangleF bounds = gerberItem.GetBounds(); //find smalles values from bounds
            if (bounds.Width < retSize.Width)
              retSize.Width = bounds.Width;
            if (bounds.Height < retSize.Height)
              retSize.Height = bounds.Height;
 
            IObjectSpecifics spec = gerberItem.GetSpecifics();
 
            switch (gerberItem.Type) //the diameter for lines and arcs is important for diagonal items
            {
              case IObjectType.Arc:
                IArcSpecifics arc = (IArcSpecifics)spec;
                if(arc.Diameter<smallestDiameter)
                  smallestDiameter = arc.Diameter;
                break;
              case IObjectType.Line:
                ILineSpecifics Line = (ILineSpecifics)spec;
                if (Line.Diameter < smallestDiameter)
                  smallestDiameter = Line.Diameter;
                break;
            }
          }
        }
      }
 
      return retSize;
    }