Adds a port.

syntaxSyntax:
DlxLayer.DrawPort(point, length, direction, name, type, bLink, style = DlxApp.PORTSTYLE_DEFAULT, flags = DlxApp.PORTFLAGS_DEFAULTS)

Parameters

Parameter Description
point A DlxPoint object with the location to insert the port.
length Specify the port length.
direction Specifies the orientation of the port. Select from the following:
DlxApp.PORTDIRECTION_LEFT
DlxApp.PORTDIRECTION_BOTTOM
DlxApp.PORTDIRECTION_RIGHT
DlxApp.PORTDIRECTION_TOP
name The name to assign to the port. To insert overlined characters in the text, they must be delimited with the '|' character. Ex: P1/|P2|
type The electrical characteristics of the port. The electric type is used during the compilation of the electrical schematic and the ERC. Select from the following:
DlxApp.PORTTYPE_UNDEFINED Port with function not clearly defined.
DlxApp.PORTTYPE_INPUT Input port.
DlxApp.PORTTYPE_OUTPUT Output port.
DlxApp.PORTTYPE_BIDIRECTIONAL Input/Output port.
bLink Specify true if the port must connect to electrical objects or false to draw only the port.
style A DlxPinStyle object with the style of the port. If the style is not specified, the appropriate style for the port type is used.
flags Specify a combination of the following values:
DlxApp.PORTFLAGS_DEFAULTS PORTFLAGS_SHOWLINE|PORTFLAGS_SHOWNAME|PORTFLAGS_VNAME|PORTFLAGS_UPDATETEXT
DlxApp.PORTFLAGS_SHOWLINE When this option is enabled, the line connecting the two characteristic points of a port is visible.
DlxApp.PORTFLAGS_UPDATETEXT Indicates whether the name should be repositioned automatically when the port is rotated.
DlxApp.PORTFLAGS_SHOWNAME Determines whether the port name is visible.
DlxApp.PORTFLAGS_VNAME Specifies the orientation of the name when the port is placed vertically.

Return Value

The newly created DlxPort object. Call the IsValid() method to determine if the object was created correctly.

Example

  Copy codeCopy code
var prj = DlxApp.GetJob().GetProject("Example Sch");
if (!prj.IsValid())
  prj = DlxApp.GetJob().NewProject("Example Sch");
var doc = prj.GetDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
if (!doc.IsValid())
{
  doc = prj.NewDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
  doc.SetPageFormat("A4", false);
}
if (doc.IsValid() && doc.Activate())
{
  var page = doc.GetActivePage();
  if (page.IsValid())
  {
    var layer = page.GetLayerFromType(DlxApp.LAYERTYPE_DRAWING);
    if (layer.IsValid())
    {
      layer.DrawPort(new DlxPoint(140, 100), 20, DlxApp.PORTDIRECTION_LEFT, "P1/|P2|", DlxApp.PORTTYPE_INPUT, true);
    }
  }
}

See also