Creates a rectangle.

syntaxSyntax:
DlxLayer.DrawRectangle(rect, rotAngle=0, blCorner=0, brCorner=0, trCorner=0, tlCorner=0)
DlxLayer.DrawRectangle(x, y, width, height, mode=DlxApp.RECTPOINT_CENTER, rotAngle=0, blCorner=0, brCorner=0, trCorner=0, tlCorner=0)
DlxLayer.DrawRectangle(point, width, height, mode=DlxApp.RECTPOINT_CENTER, rotAngle=0, blCorner=0, brCorner=0, trCorner=0, tlCorner=0)

Parameters

Parameter Description
rect A DlxRect object that specify the rectangle to be drawn.
x Horizontal position of a point in the rectangle. The position of the point in the rectangle is specified in the mode parameter.
y Vertical position of a point in the rectangle. The position of the point in the rectangle is specified in the mode parameter.
width A positive value that defines the width of the rectangle.
height A positive value that defines the height of the rectangle.
point A DlxPoint object that specifies a point in the rectangle. The position of the point in the rectangle is specified in the mode parameter.
mode To indicate the position of the point in the rectangle specify one of the following values:
DlxApp.RECTPOINT_CENTER
DlxApp.RECTPOINT_BOTTOMLEFT
DlxApp.RECTPOINT_BOTTOMRIGHT
DlxApp.RECTPOINT_TOPLEFT
DlxApp.RECTPOINT_TOPRIGHT
DlxApp.RECTPOINT_BOTTOMCENTER
DlxApp.RECTPOINT_TOPCENTER
DlxApp.RECTPOINT_MIDDLELEFT
DlxApp.RECTPOINT_MIDDLERIGHT
rotAngle The angle, in degrees, of rotation of the rectangle with respect to the x-axis.
blCorner Specify the shape of the bottom left corner.
brCorner Specify the shape of the bottom right corner.
trCorner Specify the shape of the top right corner.
tlCorner Specify the shape of the top left corner.

Return Value

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

Remarks

You can draw a rectangle or square with rounded or beveled corners. The rounding produces a curved corner, the bevel replaces the corner with a straight edge.

To draw rectangles or squares with rounded or blunted corners, you must specify the size of the angle. To round an angle, the angle dimensions determine the radius of the angle. The radius is measured from the center of the curve to its perimeter. Higher values produce more rounded or blunted corners. The size value for beveling an angle represents the distance for setting the starting point of the bevel to the original angle. Higher values produce a longer beveled edge.

The dimensions of the angle should be indicated as a percentage. Enter values between -100 and +100. The value of 0% indicates that the corners of the rectangle are at 90°. Negative values produce a blunt edge while positive values produce a rounded edge.

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 rect = new DlxRect(50,40,120,90);
      layer.DrawRectangle(rect, 0, 50, 0, 0, 50);
    }
  }
}

See also