Scales an object.

syntaxSyntax:
DlxObject.Scale(factorX, factorY)
DlxObject.Scale(factorX, factorY, basePoint)

Parameters

Parameter Description
factorX The factor by which to scale the object horizontally.
factorY The factor with which to scale the object vertically.
basePoint A DlxPoint coordinates specifying the base point.

Return Value

If the operation ends correctly it returns true otherwise it returns false.

Remarks

The dimensions of the object are multiplied by the scale factor. A scale factor greater than 1 enlarges the object. A scale factor between 0 and 1 reduces the object. The scale factor must be greater than 0.0.

If the base point is not specified, the transformation is performed with respect to the object hotspot.

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())
    {
      // create objects
      var pen = new DlxPenStyle(0.5, new DlxColor("orangered"), "DASHED");
      doc.SetStyle(pen);
      var obj = layer.DrawRectangle(new DlxRect(50,40,120,90), 0, 50, 0, 0, 50);
       // scale object
      var dlg = new DlxDialog(200, 120, "Scale");
      if (dlg.IsValid())
      {
        dlg.AddStaticText(20, 23, 60, "factor h:");
        var factorh = dlg.AddEditNumber(90, 20, 100, DlxApp.DIALOGEDITNUMBER_FLOAT, 1, 0.1, 10);
        dlg.AddStaticText(20, 48, 60, "factor v:");
        var factorv = dlg.AddEditNumber(90, 45, 100, DlxApp.DIALOGEDITNUMBER_FLOAT, 1, 0.1, 10);
        dlg.AddOkButton(80, 80, 50, 25);
        dlg.AddCancelButton(140, 80, 50, 25);
        if (dlg.DoModal())
        {
          obj.Scale(factorh.GetNumber(), factorv.GetNumber());
        }
      }
    }
  }
}

See also