Als einfaches Beipiel finden Sie hier den Code, wie man eine Linie erstellt, gefolgt von einem Button-Event, das eine Lage hinzufügt und eine Methode nutzt, um eine neue Linien auf dieser Lage zu erstellen.
Am Ende steht eine Methode, die die Werkzeugdefinition im PCB-Investigator überprüft und ein neues Werkzeug erstellt, falls das gesuchte nicht existiert.
Hier finden Sie den Beispielcode in C# und 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;
}