Hier finden Sie den Beispielcode in C# und VB:

Das Beispiel zeigt, wie Sie mit dem PCB-Investigator eine Grafik aus für Sie interessanten Daten generieren lassen können. Falls Sie die sichtbaren Bereiche abspeichern wollen, gibt es dafür eine einfache Methode in IPCBIWindow:

//for current view you can use this example:
Bitmap curView = mainWindowPCBI.GetCurrentPicture();
curView.Save(@"C:\E\tests\curView.png", System.Drawing.Imaging.ImageFormat.Png);

Andernfalls können sie den Durchgang (step) benutzen, um eine Grafik einer Lagenliste und eines definierten Bereiches erstellen zu lassen:

IPCBIWindow mainWindowPCBI; //fill e.g. in load or on other button click with mainWindowPCBI = IAutomation.CreateNewPCBIWindow(true);
    private void buttonExportImage_Click(object sender, EventArgs e)
    {
      IStep step = mainWindowPCBI.GetCurrentStep();
      if (step == null) return;
      
      ICMPLayer layerCMPsTop = step.GetCMPLayer(true);
      //exisits the compnenent layer?
      if (layerCMPsTop == null) return;
 
      List<IObject> layerObjectList = layerCMPsTop.GetAllLayerObjects();
      //is there a compnent on the layer?
      if (layerObjectList.Count == 0) return;
 
      //for the example we use the first component, you can search for each component attribut you want
      SaveImageFromComponent((ICMPObject)layerObjectList[0], step, @"C:\E\tests\");
 
      //something went wrong?
      string errorLog = IAutomation.GetErrorLog();
      if(errorLog.Length>0)
        System.Diagnostics.Debug.WriteLine(errorLog);
    }
    /// <summary>
    /// This example shows how to make an image of an component with connections on the signal layer below.
    /// </summary>
    /// <param name="CMPforImage">The relevant component</param>
    /// <param name="step">current step from the component</param>
    /// <param name="FileLocation">Where should we save the image?</param>
    public void SaveImageFromComponent(ICMPObject CMPforImage, IStep step, string FileLocation)
    {
      List<ILayer> layers = new List<ILayer>(); //for the image we need all layers who are visible
 
      ICMPLayer CMPlayer = step.GetCMPLayer(CMPforImage.PlacedTop);
      IODBLayer outsideSignalLayer = step.GetOutsideODBLayer(CMPforImage.PlacedTop);
 
      if (CMPlayer == null) return; //check the layer is existing? maybe wrong job?
      layers.Add(CMPlayer);
 
      if (outsideSignalLayer != null) //we want to see where are pins connected
        layers.Add(outsideSignalLayer);
 
      RectangleF boundsRelevantCMP = CMPforImage.GetBounds();
      boundsRelevantCMP.Inflate(100, 100); //show a little bit of the area around the component
 
      //create the image and save it as png
      PCBI.Automation.IStep.BitmapResultClass imageClass = step.GetBitmap(layers, boundsRelevantCMP, 500, 500);
      if (imageClass != null)
        imageClass.Image.Save(FileLocation + CMPforImage.Ref + ".png", System.Drawing.Imaging.ImageFormat.Png);
 
    }