我想这就是你要找的。我在没有 IDE 的情况下录制了这个,所以检查一下。
using AcApp = Autodesk.Autocad.ApplicationServices.Application;
public class yourclass
{
public Document AcDoc {
get { return AcApp.DocumentManager.MdiActiveDocument;}
}
public static void getSelectionSet()
{
var _editor = AcDoc.Editor;
var _selAll = ed.SelectAll();
var _SelectionSet = _selAll.Value;
using(var trans = AcDoc.TransactionManager.StartTransaction()){
foreach(var ObjId in _SelectionSet.GetObjectIds()){
// apply logic
}
trans.Commit();
}
}
或者如果你想返回一个 SelectionSet
public class yourclass
{
public Document AcDoc {
get { return AcApp.DocumentManager.MdiActiveDocument;}
}
public static SelectionSet getSelectionSet()
{
var _editor = AcDoc.Editor;
var _selAll = ed.SelectAll();
return _selAll.Value;
}
}
原谅格式,我不能让它在堆栈上正常工作