Create a new group consisting of all objects in the selection.

syntaxSyntax:
DlxSelection.Group(name)

Parameters

Parameter Description
name The name to be given to the group.

Return Value

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

Remarks

The Group method creates a new object and deletes all the selected objects from the document.

The image of a page, the path object, electrical objects and PCB objects cannot be grouped.

When the selected objects belong to different layers, the objects in the group move to the current layer. The objects keep the order of overlap with respect to the other objects in the group. However, since they are all on the active layer, their stacking order may be changed in relation to other objects that are not part of the group or are on different levels.

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"), "SOLID");
      doc.SetStyle(pen);
      var obj1 = layer.DrawLine(new DlxPoint(30, 30), new DlxPoint(80, 80));
      var obj2 = layer.DrawEllipse(new DlxPoint(80, 80), 10);
      // group the objects
      var selection = page.GetSelection();
      selection.Empty();
      selection.AddObject(obj1);
      selection.AddObject(obj2);
      selection.Group("Line and Circle");
    }
  }
}

See also