Dieses Beispiel demonstriert den einfachen Umgang mit Netzelementen. Die INet Klasse ermöglicht es Ihnen alle Netzitems zu erhalten und mit ihnen zu arbeiten. In diesem Beispiel nehmen wir alle Netze des ersten Durchlaufs und weisen ihnen eine Farbe zu.

Hier finden Sie den Beispielcode in C# und VB:

/// <summary>
    /// Button click event to start the example
    /// </summary>
    private void buttonNetColors_Click(object sender, EventArgs e)
    {
      IAutomation.IAutomationInit();
 
      //create a window to handle your actions
      IPCBIWindow mainWindowPCBI = IAutomation.CreateNewPCBIWindow(false);
 
      //then load a job
      mainWindowPCBI.LoadODBJob(@"C:\D\Jobs\DemoJob");
 
      SetNetColors(mainWindowPCBI);
 
      //looks better with xor colormixing, special replace same color on different layers with black
      mainWindowPCBI.IColorsetting.ColorMix = PCBI.DrawingMode.xor;
      mainWindowPCBI.Show();
    }
    /// <summary>
    /// Set colors for all nets in the first step.
    /// </summary>
    /// <param name="PCBI">The used main window.</param>
    public void SetNetColors(IPCBIWindow PCBI)
    {
      //take the first step
      IStep firstStep = PCBI.GetCurrentStep();
 
      List<INet> allNets = firstStep.GetNets();
 
      int netcounter = 1;
      foreach (INet net in allNets)
      {
        //generate special color for this net
        Color netcolor = GetNewColor(netcounter);
 
        //go through all net elements and set the color
        foreach (IODBObject netItem in net.GetAllNetObjects(PCBI))
        {
          netItem.ObjectColor = netcolor;
        }
 
        netcounter++;
      }
    }
    /// <summary>
    /// Example method to generate different colors, limited colors but for the example ok.
    /// </summary>
    /// <param name="usedColors">counter for all used nets to generate different colors</param>
    /// <returns>Color for one net</returns>
    public Color GetNewColor(int usedColors)
    {
      switch (usedColors % 3)
      {
        case 0:
          return Color.FromArgb(usedColors % 255, 0, 32 + usedColors % 128);
          break;
        case 1:
          return Color.FromArgb(0, 64 + usedColors % 128, usedColors % 255);
          break;
        case 2:
          return Color.FromArgb(128 + usedColors % 128, usedColors % 255, 0);
          break;
      }