Gets the number of pins in this component.

syntaxSyntax:
DlxNetlistDevice.GetPinCount()

Return Value

Returns the number of pins in this device.

Example

  Copy codeCopy code
var project = DlxApp.GetJob().GetProject();
if (!project.IsValid())
{
  throw new Error("Project not found.");
}

var netlist = project.GetNetlist();
if (!netlist.IsValid())
{
  throw new Error("Invalid netlist.");
}

var valLen = 31;
var refLen = 14;
var devicesort = new DlxSort(DlxApp.SORT_TEXTFIRSTINT, false);
for (var i = 0; i < netlist.GetDeviceCount(); i++)
{
  var device = netlist.GetDevice(i);
  valLen = Math.max(valLen, device.GetValue().length);
  refLen = Math.max(refLen, device.GetReference().length);
  devicesort.AddString(device.GetReference(), i);
}
devicesort.Sort();

var pinNumLen = 7;
var pinNameLen = 14;
var pinTypeLen = 14;
for (i = 0; i < netlist.GetNetCount(); i++)
{
  var net = netlist.GetNet(i);
  if (net.GetPinCount() > 1)
  {
    for (var j = 0; j < net.GetPinCount(); j++)
    {
      var pin = net.GetPin(j);
      pinNumLen = Math.max(pinNumLen, pin.GetNumber().length);
      pinNameLen = Math.max(pinNameLen, pin.GetName().length);
      pinTypeLen = Math.max(pinTypeLen, pin.GetTypeName().length);
    }
  }
}

var deviceFormat = DlxApp.Format("%%-%is %%-%is %%-%is", valLen, refLen, refLen);
var lineFormat = DlxApp.Format("%%-7s %%-%is %%-%is %%-%is %%-%is %%s", refLen, pinNumLen, pinNameLen, pinTypeLen);

var file = new DlxFile("temp\\netlist.txt", DlxApp.FILEOPEN_WRITETEXT);
if (!file.IsValid())
{
  throw new Error("Unable to open file.");
}
file.Write("Wire List\n\n");

file.Write("<<< Component List >>>\n");
for (i = 0; i < devicesort.GetCount(); i++)
{
  device = netlist.GetDevice(devicesort.GetData(i));
  file.Write(DlxApp.Format(deviceFormat, device.GetValue(), device.GetReference(), "")+"\n");
}

var count = 0;
file.Write("\n<<< Wire List >>>\n");
file.Write(DlxApp.Format(lineFormat, "NODE", "REFERENCE", "PIN #", "PIN NAME", "PIN TYPE", "PART VALUE")+"\n");
for (i = 0; i < netlist.GetNetCount(); i++)
{
  net = netlist.GetNet(i);
  if (net.GetPinCount() > 1)
  {
    file.Write(DlxApp.Format("[%.5i] %s\n", ++count, net.GetName()));
    for (j = 0; j < net.GetPinCount(); j++)
    {
      pin = net.GetPin(j);
      device = pin.GetDevice();
      file.Write(DlxApp.Format(lineFormat, "", device.GetReference(), pin.GetNumber(), 
       pin.GetName(), pin.GetTypeName(), device.GetValue())+"\n");
    }
  }
}
DlxApp.Printf("ICONINFORMATIONNetlist saved in %s", file.GetFilePath());

See also