Define a new fill pattern.

syntaxSyntax:
DlxHatchStyle.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

The fill pattern is defined by one or more description lines. Each line is in the following form:

AttenzioneSyntax:
<angle>, <x origin>, <y origin>, <delta x>, <delta y> [,<dash>]*

The individual numbers in the sequence must be separated by at least one space character or a comma. The angle is in degrees and the lengths are expressed in millimetres.

The pattern consists of one or more lines. Each line is considered the first member of a family of parallel lines that is generated by drawing the first one and applying a translation in both directions. The delta value y indicates the spacing between family members perpendicular to the lines. Delta x provides the translation between the lines in the direction of the line itself. This value has meaning if it produces a visible effect, on continuous lines it would be useless, while on dashed lines, the dashes themselves, staggered from one line to another, produce a visible effect.

Terms describing the line hatching (dash) are optional and should only be indicated in the case of dashed lines. Hatching is defined by a series of numbers that specify the lengths of the individual strokes. Each dash length specifies a segment that will make up the line. If the value indicating the length is positive, the segment is drawn; if the value is negative, the segment is not drawn, but instead there will be a space equal in length to that specified. The pattern starts with its first segment, from the point of origin, by drawing the specified segments in a cyclic way. A hyphen length equal to zero causes a point to be drawn.

Example:

To define a pattern with 45-degree sloping lines and 5 millimeter spacing, specify the sequence:

45, 0, 0, 0, 5

This notation indicates that the lines must be drawn at an angle of 45 degrees, that the first filling line must pass through the point (0.0), and that the spacing between the lines is 5 millimetres.

To the previous pattern are added the indications for the segments of the dotted line specifying a length of the section of 5 millimetres and that of the space of even 5 millimetres:

45, 0, 0, 0, 5, 5, -5

This notation generates dashed lines with 5 mm long segments, 5 mm line spacing and 45 degree lines.

If the pattern is described with several lines, very complex filling patterns can be obtained. The following is a description of a filling pattern consisting of squares of 5 mm side.

90 0 0 0 10 5 -5
0 0 5 0 10 5 -5
270 5 5 0 10 5 -5
0 0 0 0 10 5 -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, "green", "DASHED");
      var brush = new DlxBrushStyle("page color");
      doc.SetStyle(pen);
      doc.SetStyle(brush);

      var rect = new DlxRect(50,40,120,90);
      layer.DrawRectangle(rect, 0, 50, 0, 0, 50);

      var hatch = new DlxHatchStyle();
      hatch.NewPattern("demohatch", "drawing", "90 0 0 0 10 5 -5\n0 0 5 0 10 5 -5\n270 5 5 0 10 5 -5\n0 0 0 0 10 5 -5");
      brush.HatchBrush(hatch, "green", "orange", 0.2);
      
      doc.SetStyle(brush);
      rect.Offset(100, 0);
      layer.DrawRectangle(rect);
    }
  }
}

See also