How to return a selection of Objects to the user (AutoCAD .net API)

You want certain objects to be selected at the end of a command. How do you do this?

ObjectId[] ids = PopulateObjectIDs(); // implement this 
Autodesk.AutoCAD.Internal.Utils.SelectObjects(ids);  
// Warning: this code is untested. I copied it and edited it from some working code. You’ll have to check for any obvious bugs etc.

And that should select any objects that you want to select. You’ll have to put it in an array though. A handy hint which can save you a bit of grief.

Hope this helps!

Written on February 21, 2017