How to create a line object

As simple demo here is the code to create a line. Following is a button event to create a layer and use the method to add the new line on this layer.

At the end is a method to check the tool definition in PCB-Investigator and create a new tool if the searched tool dos not exist.

Here is the example code in C Sharp and VB:

/// <summary>
    /// This methode creates a line in PCB-Investigator.
    /// </summary>
    /// <param name="pcbiFilter">The object creating class of PCB-I.</param>
    /// <param name="matrix">The job matrix in PCB-I (IPCBIWindow.GetMatrix()).</param>
    /// <param name="parentLayer">The layer on which the object should be created.</param>
    /// <param name="lineStart">The start point of the line.</param>
    /// <param name="lineEnd">The end point of the line.</param>
    /// <param name="thickness">The diameter of the line.</param>
    /// <param name="NetName">The netname if you want to use it.</param>
    /// <param name="step">The current step in PCB-I (e.g. IPCBIWindow.GetCurrentStep())</param>
    internal void CreateLine(IFilter pcbiFilter, IMatrix matrix, IODBLayer parentLayer, PointF lineStart, PointF lineEnd, float thickness, String NetName, IStep step)
      IODBObject line = pcbiFilter.CreateLine(parentLayer); //create a new line object
      ILineSpecifics specLine = (ILineSpecifics)line.GetSpecifics(); //the specifics of the object to fill the informations
      specLine.Start = lineStart;
      specLine.End = lineEnd;
      specLine.ShapeIndex = CheckShapeIndexRound(pcbiFilter, parentLayer, thickness); //In PCB-Investigator all objects have a shape index for drawing.
      specLine.Diameter = thickness;
      specLine.Positive = true;
      specLine.Type = PCBI.Symbol_Type.r; //definition of the line ends, most lines are rounds(r)
      line.SetSpecifics(specLine, specLine.ShapeIndex); //activate the setting!
IPCBIWindow window;
IStep step; //e.g. window.GetCurrentStep();
private void buttonAddLineAndLayerToExistingStep_Click(object sender, EventArgs e)
PCBI.Automation.IFilter filter = new PCBI.Automation.IFilter(window);
IODBLayer layer = filter.CreateEmptyODBLayer("layer1", step.Name);
CreateLine(filter, matrix, layer, new PointF(10, 10), new PointF(150, 10), 10, "", step);
/// <summary>
    /// Example to create or load a round tool.
    /// </summary>
    /// <param name="pcbiFilter">To check the known tools</param>
    /// <param name="parentLayer">Each layer needs his own tool definitions.</param>
    /// <param name="diameter">The thickness of the round tool.</param>
    /// <returns>The shape Index for later use.</returns>
    internal static int CheckShapeIndexRound(IFilter pcbiFilter, IODBLayer parentLayer, float diameter)
      int shapeIndex = -1;
      Dictionary<int, PCBI.Automation.IFilter.ToolDefinition> symbolList = pcbiFilter.GetUsedSymbolList(parentLayer);
      foreach (KeyValuePair<int, PCBI.Automation.IFilter.ToolDefinition> symbs in symbolList)
        if (symbs.Value.Diameter == diameter
          && symbs.Value.Type == PCBI.Symbol_Type.r)
          return symbs.Key; //If the tool is allready known, we do not create a second one!
      shapeIndex = IFilter.AddToolDefinitionRound(parentLayer, diameter, 1);
      return shapeIndex;