Winslow North
Winslow North

Reputation: 25

Add entities to an Autocad commands selection set

what i want to do is something similar to the code below. but rather than remove entities from the selection set i want to add entities that contain certain xdata. is this possible or am i asking for the moon? the link below is for the code shown here.

SelectionAddedEventHandler

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);
}
}

Upvotes: 1

Views: 1213

Answers (1)

EricM
EricM

Reputation: 787

Have you tried something like this yet?

ObjectId acObjId = //the object id of the xdata object 
SelectedObject obj = new SelectedObject(acObjId, null);
e.Add(obj);

Upvotes: 2

Related Questions