我想要做的是类似于下面的代码。但是我想要添加包含某些xdata的实体,而不是从选择集中删除实体。这是可能还是我要月亮?下面的链接是针对此处显示的代码。
public class MyCommands
{
[CommandMethod("MyReactor")]
public void MyReactor()
{
Editor ed = acApp.DocumentManager.MdiActiveDocument.Editor;
ed.SelectionAdded += new SelectionAddedEventHandler(ed_SelectionAdded);
}
void ed_SelectionAdded(object sender, SelectionAddedEventArgs e)
{
string cmds = (string)acApp.GetSystemVariable("CMDNAMES");
if (!cmds.StartsWith("COPY"))
return;
int i = 0;
List<int> indices = new List<int>();
foreach (SelectedObject selObj in e.AddedObjects)
{
if (selObj.ObjectId.ObjectClass == RXClass.GetClass(typeof(Circle)))
indices.Insert(0, i);
i++;
}
foreach (int current in indices)
e.Remove(current);
}
}
答案 0 :(得分:2)
你有没有试过这样的东西呢?
ObjectId acObjId = //the object id of the xdata object
SelectedObject obj = new SelectedObject(acObjId, null);
e.Add(obj);