C# 使用UsePickSet时,选择集在命令后清除
我必须使用预选的多段线集运行命令。因此,我使用UsePickSet 命令发出后,我需要通过亮显/选择一组较小的过滤多段线来向用户指示。处理后,我将这些添加到selectionset 但是,如果我们在方法属性中提到CommandFlags.UsePickSet,那么当命令结束时,它会自动清除选择集,即使它已更改 有没有办法克服这个问题 如果有人想试试,我做了一个POC。SETACADHANDRESELECTION1将保留选择,而SETACADHANDRESELECTION2将不保留选择C# 使用UsePickSet时,选择集在命令后清除,c#,autocad,C#,Autocad,我必须使用预选的多段线集运行命令。因此,我使用UsePickSet 命令发出后,我需要通过亮显/选择一组较小的过滤多段线来向用户指示。处理后,我将这些添加到selectionset 但是,如果我们在方法属性中提到CommandFlags.UsePickSet,那么当命令结束时,它会自动清除选择集,即使它已更改 有没有办法克服这个问题 如果有人想试试,我做了一个POC。SETACADHANDRESELECTION1将保留选择,而SETACADHANDRESELECTION2将不保留选择 [
[CommandMethod("GetACADHandle", CommandFlags.UsePickSet)]
public static void GetACADHandle()
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult res = ed.SelectImplied();
if (res.Status != PromptStatus.Error)
{
var pline = res.Value[0].ObjectId;
ed.WriteMessage(pline.Handle.ToString());
// SetACADHandleSelection(pline.Handle.ToString());
}
}
[CommandMethod("SetACADHandleSelection1")]
public static void SetACADHandleSelection1(string handle)
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
if (string.IsNullOrWhiteSpace(handle))
{
PromptResult res = ed.GetString("Enter acad Handle");
if (res.Status != PromptStatus.Error)
{
handle = res.StringResult;
}
}
if (!string.IsNullOrWhiteSpace(handle))
{
using (Transaction Tx = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
Handle handlep = new Handle(Convert.ToInt64(handle, 16));
ObjectId objId = db.GetObjectId(false, handlep, 0);
ed.SetImpliedSelection(new ObjectId[] { objId });
}
}
}
[CommandMethod("SetACADHandleSelection2", CommandFlags.UsePickSet)]
public static void SetACADHandleSelection2(string handle)
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
if (string.IsNullOrWhiteSpace(handle))
{
PromptResult res = ed.GetString("Enter acad Handle");
if (res.Status != PromptStatus.Error)
{
handle = res.StringResult;
}
}
if (!string.IsNullOrWhiteSpace(handle))
{
using (Transaction Tx = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
{
Handle handlep = new Handle(Convert.ToInt64(handle, 16));
ObjectId objId = db.GetObjectId(false, handlep, 0);
ed.SetImpliedSelection(new ObjectId[] { objId });
}
}
}
尝试使用CommandFlags。重新绘制 欲了解更多信息,请访问: 请看,如果共识是否定的,他们就不应该这样做!