To create your own C# application with using of PCB-Investigator is very simple. First you have to add the reference to your project. In this example its only necessary to add one using from PCB-Investigator: using PCBI.Automation;

For easy starting we have added one button to start the creation.

This simple example can also be updated with net informations.

Here is the example code in C Sharp and VB:

private void buttonCreateJobAndAddDemoLayers_Click(object sender, EventArgs e)
    {
      IPCBIWindow window;
      if (parent == null)
      //create a new instance of PCB-Investigator
      {
        window = PCBI.Automation.IAutomation.CreateNewPCBIWindow(true);
        parent = window;
      }
      else
        //use the existing instance
        window = parent;
 
      PCBI.Automation.IFilter filter = new PCBI.Automation.IFilter(window);
 
      #region create new job
      try
      {
        string JobFullPath = filter.CreateAndLoadEmptyJob(@"C:\tests\FilterTests\Job1");
      }
      catch (Exception ex)
      {
        MessageBox.Show("Can't create new JobDirectory!\n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return;
      }
      #endregion
 
      #region new layer
      CreateDemoODBLayer(filter);
 
      #endregion
 
      #region CMP-layer
      CreateDemoCMPLayer(window, filter);
      #endregion
    }
 
    /// <summary>
    /// This method creates an new component layer and add an cmp with some demo pins.
    /// </summary>
    /// <param name="window">The parent window to add the layer and cmp.</param>
    /// <param name="filter">An IFilter object to create the new items.</param>
    private static void CreateDemoCMPLayer(IPCBIWindow window, PCBI.Automation.IFilter filter)
    {
      ICMPLayer parentCMP = window.GetCurrentStep().GetCMPLayer(true);
      if (parentCMP == null)
        parentCMP = filter.CreateEmptyCMPLayer("cmp_top", "gerber"); //in this example the stepname is "gerber"
      ICMPObject component = filter.CreateComponent(parentCMP);
 
      IPackageSpecifics pack = filter.CreatePackage("testPack"); //one package for the demo-cmp
      #region outline of package
      GraphicsPath gp = new GraphicsPath();
 
      gp.AddLine(new Point(100, 100), new Point(100, 300));
      gp.AddLine(new Point(100, 300), new Point(300, 300));
      gp.AddLine(new Point(300, 300), new Point(300, 100));
      gp.AddLine(new Point(300, 100), new Point(100, 100));
 
      pack.SetGraphicsPath(gp);
      #endregion
 
      pack.AddEllipsePin(new PointF(101, 101), 35, "PinEl1");
      pack.AddRectanglePin(new RectangleF(279, 269, 40, 50), "PinRe1");
 
      #region more pins
      for (int i = 0; i < 5; i++)
      {
        ISurfaceSpecifics outline = pack.CreatePolygonPinSurface();
        outline.StartPolygon(false, new PointF(20, 50));
        outline.AddLine(new PointF(20, 50), new PointF(20, 70));
        outline.AddLine(new PointF(20, 70), new PointF(35, 70));
 
        outline.AddArc(new PointF(35, 70), new PointF(40, 65), new PointF(35, 65), true);
 
        outline.AddLine(new PointF(40, 65), new PointF(40, 50));
        outline.AddLine(new PointF(40, 50), new PointF(20, 50));
        outline.EndPolygon();
        pack.AddPolygonPin(new PointF(100 + i * 20, 150 + 1 * 5), outline, "PinPo" + i); //add the polygon pin with nr
      }
      #endregion
 
      var specifics = component.GetSpecifics();
      IComponentSpecifics spec = (IComponentSpecifics)specifics;
      spec.Height = 7;
      spec.Location = new PointF(1000, 500);
      spec.PartName = "partName2";
      spec.Value = "value2";
      spec.Attributes = "attributes2";
      spec.Reference = "Ref2";
      spec.PlacedTop = true;
 
      component.SetSpecifics(spec, pack);
    }
 
    /// <summary>
    /// An example to create an new layer and add some objects to show how to handle simple properties.
    /// </summary>
    /// <param name="filter">The IFilter object to create the elements.</param>
    private void CreateDemoODBLayer(PCBI.Automation.IFilter filter)
    {
      IODBLayer layer = filter.CreateEmptyODBLayer("layer1", "gerber");
 
      //tooldefinitions
      int index1 = IFilter.AddToolDefinitionRound(layer, 10, 0);
      int index2 = IFilter.AddToolDefinitionRect(layer, 20, 1, 20, 50, true);
      int index3 = IFilter.AddToolDefinitionDonut(layer, 50, 25, 2);
      int index4 = IFilter.AddToolDefinitionOct(layer, 40, 40, 40, 5, 3);
 
      #region firstArc
      //create an arc object
      IODBObject arc = filter.CreateArc(layer);
      IArcSpecifics specificsArc = new IArcSpecifics();
      specificsArc.Start = new PointF(100, 100);
      specificsArc.End = new PointF(100, 300);
      specificsArc.Center = new PointF(100, 200);
      specificsArc.ClockWise = true;
      specificsArc.Positiv = true;
      specificsArc.Diameter = 10;
      arc.SetSpecifics(specificsArc, 0);
      #endregion
 
      #region first+second+third Pad
      //create three pads
      IODBObject pad = filter.CreatePad(layer);
      IPadSpecifics padInfos = new IPadSpecifics();
      padInfos.Location = new PointF(400, 400);
      padInfos.Positiv = (true);
      pad.SetSpecifics(padInfos, index1); //its possible to use the same index more than one time
 
      IODBObject pad2 = filter.CreatePad(layer);
      padInfos = new IPadSpecifics();
      padInfos.Location = new PointF(300, 400);
      padInfos.Positiv = (true);
      pad2.SetSpecifics(padInfos, index2);
 
      IODBObject pad3 = filter.CreatePad(layer);
      padInfos = new IPadSpecifics();
      padInfos.Location = new PointF(200, 400);
      padInfos.Positiv = (true);
      pad3.SetSpecifics(padInfos, index3);
      #endregion
    }