Creates a polygon from a list of vertices.

syntaxSyntax:
DlxLayer.DrawPolygon(vertices)

Parameters

Parameter Description
vertices An array of DlxPoint objects with the coordinates used to create the polygon vertices.

Return Value

The last newly created DlxShape 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())
    {
      var size = 10;
      var sides = 6;
      var index = 0;
      var step = Math.PI * 2 / sides;
      var center = new DlxPoint(80, 90);
      var vertices = new Array();
      for (var angle = 0; angle < Math.PI*2; angle += step)
      {
        vertices[index++] = center.Offset(new DlxPoint(size * Math.cos(angle), size * Math.sin(angle)));
      }
      vertices[index++] = vertices[0];
      layer.DrawPolygon(vertices);
    }
  }
}

See also