Activate the tool to acquire an object.

syntaxSyntax:
DlxGraphixDocument.ToolPickObject(messageString, bMultiPick)

Parameters

Parameter Description
messageString The message to be displayed in the status bar.
bMultiPick Specifies whether the choice box should be displayed when the user clicks on multiple overlapping objects. If this value is false only the foreground object is captured.

Return Value

Returns the DlxObject. Call the IsValid() method to determine if the object is valid.

Example

  Copy codeCopy code
function OnMenu()
{
  var menu = DlxApp.GetMenu(DlxApp.MENU_SCH);
  if (menu.IsValid())
  {
    menu.AddCommand("Pick Object", 100, "Activate the tool to acquire an object. ");
    menu.AddCommand("Pick Point", 200, "Activate the tool to acquire the coordinates of a point.");
    menu.AddCommand("Pick Segment", 300, "Activate the tool to acquire the coordinates of a line segment.");
    menu.AddCommand("Pick Rect", 400, "Activate the tool to acquire the coordinates of a rectangle.");
  }
}

function OnMenuUpdateCommand(cmd)
{
  switch (cmd.GetCommandId())
  {
    case 100:
    case 200:
    case 300:
    case 400:
      cmd.Enable(true);
      break;
  }
}

function OnMenuCommand(cmdId)
{
  switch (cmdId)
  {
  case 100:
    PickObject();
    break;
  case 200:
    PickPoint();
    break;
  case 300:
    PickSegment();
    break;
  case 400:
    PickRect();
    break;
  }
} 

function PickObject()
{
  var doc = DlxApp.GetActiveDocument();
  if (doc.IsValid())
  {
    if ((doc.GetDocumentType() == DlxApp.DOCTYPE_DRAWING) ||
        (doc.GetDocumentType() == DlxApp.DOCTYPE_SCHEMATIC))
    {
      var obj = doc.ToolPickObject("Click on the object.", false);
      DlxApp.Printf("Picked object: %s", obj.GetTypeName());
    }
  }
}

function PickPoint()
{
  var doc = DlxApp.GetActiveDocument();
  if (doc.IsValid())
  {
    if ((doc.GetDocumentType() == DlxApp.DOCTYPE_DRAWING) ||
        (doc.GetDocumentType() == DlxApp.DOCTYPE_SCHEMATIC))
    {
      var point = doc.ToolPickPoint(0, 1);
      DlxApp.Printf("Point: %.1f,%.1f", point.x, point.y);
    }
  }
}

function PickSegment()
{
  var doc = DlxApp.GetActiveDocument();
  if (doc.IsValid())
  {
    if ((doc.GetDocumentType() == DlxApp.DOCTYPE_DRAWING) ||
        (doc.GetDocumentType() == DlxApp.DOCTYPE_SCHEMATIC))
    {
      var seg = doc.ToolPickPoint(0, 2);
      DlxApp.Printf("Segment: p1(%.1f.%.1f) p2(%.1f.%.1f)", seg.p1.x, seg.p1.y, seg.p2.x, seg.p2.y);
    }
  }
}

function PickRect()
{
  var doc = DlxApp.GetActiveDocument();
  if (doc.IsValid())
  {
    if ((doc.GetDocumentType() == DlxApp.DOCTYPE_DRAWING) ||
        (doc.GetDocumentType() == DlxApp.DOCTYPE_SCHEMATIC))
    {
      var seg = doc.ToolPickPoint(0, 2, DlxApp.TOOLPICKPOINT_SHOWRECT);
      DlxApp.Printf("Segment: p1(%.1f.%.1f) p2(%.1f.%.1f)", seg.p1.x, seg.p1.y, seg.p2.x, seg.p2.y);
    }
  }
}

See also