The PickFirst selection set is created when you select objects prior to starting a command. Several conditions must be present in order to obtain the objects of a PickFirst selection set, these conditions are:
PickFirst 选择集是在先选择对象后启动命令的时候创建的。为了获得 PickFirst 选择集的对象,必须满足某些条件,这些条件是:
The SetImpliedSelection method is used to clear the current PickFirst selection set.
SetImpliedSelection 方法用于清除当前的 PickFirst 选择集。
This example displays the number of objects in the PickFirst selection set and then requests the user to select additional objects. Before requesting the user to select objects, the current PickFirst selection set is cleared with the SetImpliedSelection method.
本例显示 PickFirst 选择集中的对象的数量然后要求用户选择另外的对象。在请求用户选择对象前,使用 SetImpliedSelection 方法将当前 PickFirst 选择集清空了。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
<CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet)> _
Public Sub CheckForPickfirstSelection()
'' 获得当前文档 Get the current document
Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor
'' 获得 PickFirst 选择集 Get the PickFirst selection set
Dim acSSPrompt As PromptSelectionResult
acSSPrompt = acDocEd.SelectImplied()
Dim acSSet As SelectionSet
'' 如果提示状态是 OK,那么对象在命令启动前已经被选择了 If the prompt status is OK, objects were selected before
'' the command was started
If acSSPrompt.Status = PromptStatus.OK Then
acSSet = acSSPrompt.Value
Application.ShowAlertDialog("Number of objects in Pickfirst selection: " & _
acSSet.Count.ToString())
Else
Application.ShowAlertDialog("Number of objects in Pickfirst selection: 0")
End If
'' 清除 PickFirst 选择集 Clear the PickFirst selection set
Dim idarrayEmpty() As ObjectId
acDocEd.SetImpliedSelection(idarrayEmpty)
'' 要求在图形区域中选择对象 Request for objects to be selected in the drawing area
acSSPrompt = acDocEd.GetSelection()
'' 如果提示状态是 OK,对象就被选择了 If the prompt status is OK, objects were selected
If acSSPrompt.Status = PromptStatus.OK Then
acSSet = acSSPrompt.Value
Application.ShowAlertDialog("Number of objects selected: " & _
acSSet.Count.ToString())
Else
Application.ShowAlertDialog("Number of objects selected: 0")
End If
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
[CommandMethod("CheckForPickfirstSelection", CommandFlags.UsePickSet)]
public static void CheckForPickfirstSelection()
{
// 获得当前文档 Get the current document
Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor;
// 获得 PickFirst 选择集 Get the PickFirst selection set
PromptSelectionResult acSSPrompt;
acSSPrompt = acDocEd.SelectImplied();
SelectionSet acSSet;
// 如果提示状态是 OK,那么对象在命令启动前已经被选择了 If the prompt status is OK, objects were selected before
// the command was started
if (acSSPrompt.Status == PromptStatus.OK)
{
acSSet = acSSPrompt.Value;
Application.ShowAlertDialog("Number of objects in Pickfirst selection: " +
acSSet.Count.ToString());
}
else
{
Application.ShowAlertDialog("Number of objects in Pickfirst selection: 0");
}
// 清除 PickFirst 选择集 Clear the PickFirst selection set
ObjectId[] idarrayEmpty = new ObjectId[0];
acDocEd.SetImpliedSelection(idarrayEmpty);
// 要求在图形区域中选择对象 Request for objects to be selected in the drawing area
acSSPrompt = acDocEd.GetSelection();
// 如果提示状态是 OK,对象就被选择了 If the prompt status is OK, objects were selected
if (acSSPrompt.Status == PromptStatus.OK)
{
acSSet = acSSPrompt.Value;
Application.ShowAlertDialog("Number of objects selected: " +
acSSet.Count.ToString());
}
else
{
Application.ShowAlertDialog("Number of objects selected: 0");
}
}