Define a new dash pattern.

syntaxSyntax:
DlxDashStyle.NewPattern(name, class, patternDefinition)

Parameters

Parameter Description
name A string with the style name.
class A string with the name of the class to which the style belongs. If this string is empty or the class does not exist, the style is not associated with a class.
patternDefinition A string with the pattern definition.

Return Value

If the operation ends correctly, it returns a string containing the public style handle, otherwise it returns an empty string. This function fails if a style with the same name already exists.

Remarks

Hatching is defined by a series of numbers that specify the lengths of the individual strokes alternating between full and empty strokes. Hatching starts with a full stroke. A dash length of zero causes a point to be drawn.

The individual numbers in the sequence must be separated by at least one space character. The lengths are expressed in millimetres and refer to a line with a thickness of one millimetre.

Example:

To define the following hatch: short section, double point, long section.
Specify the sequence: 10 5 0 5 0 5 20 5

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 pen = new DlxPenStyle(0.5, new DlxColor("orangered"), "DASHED");
      doc.SetStyle(pen);
      layer.DrawLine(new DlxPoint(30, 30), new DlxPoint(80, 80));

      var dashstyle = new DlxDashStyle();
      dashstyle.NewPattern("A1", "drawing", "10 5 0 5 0 5 20 5");
      pen.SetDashStyle("A1");

      doc.SetStyle(pen);
      layer.DrawLine(new DlxPoint(40, 30), new DlxPoint(90, 80));
    }
  }
}

See also