Posts: 216
Registered: ‎08-24-2010
Message 11 of 14 (221 Views)

Re: This is my completely code

06-28-2013 12:13 PM in reply to: DiningPhilosopher

Yes I can change the filter criteria at any time. but before start the selection


so , how can i after the selection method start >

see my completly code in the sub "handle_KeywordInput"  in selection case "Object" , i change what user what filter to selectionset do.


understand me?

*Expert Elite*
Posts: 2,084
Registered: ‎04-29-2006
Message 12 of 14 (139 Views)

Re: This is my completely code

06-30-2013 12:49 AM in reply to: Amremad

No, as DiningPhilosopher said, using Editor.SelectionAdded you can change the way you filter objects after the selection started.


Try this little snippet, it starts filtering lines and you can change the filtered entities to circles or polylines during the selection. The selection set keeps previously selected objects.


using System.Collections.Generic;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

namespace SelectionSample
    public class CommandMethods
        // current keyword filter
        private string keyWord;

        public void Test()
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            // (re)set default filter
            this.keyWord = "LIne";

            PromptSelectionOptions opt = new PromptSelectionOptions();
            opt.SetKeywords("[CIrcle/LIne/POlyline]", "CIrcle LIne POlyline");
            opt.MessageForAdding = "\nSelect objects or " + opt.Keywords.GetDisplayString(true);
            opt.KeywordInput += onKeywordInput;

            ed.SelectionAdded += onSelectionAdded;
            PromptSelectionResult psr = ed.GetSelection(opt);
            ed.SelectionAdded -= onSelectionAdded;
            if (psr.Status == PromptStatus.OK)

        private void onKeywordInput(object sender, SelectionTextInputEventArgs e)
            this.keyWord = e.Input;

        private void onSelectionAdded(object sender, SelectionAddedEventArgs e)
            RXClass rxc;
            switch (this.keyWord)
                case "POlyline": rxc = RXClass.GetClass(typeof(Polyline)); break;
                case "CIrcle": rxc = RXClass.GetClass(typeof(Circle)); break;
                default: rxc = RXClass.GetClass(typeof(Line)); break;
            ObjectId[] ids = e.AddedObjects.GetObjectIds();
            for (int i = 0; i < ids.Length; i++)
                if (ids[i].ObjectClass != rxc)


Gilles Chanteau
Posts: 216
Registered: ‎08-24-2010
Message 13 of 14 (118 Views)

Re: This is my completely code

07-01-2013 12:56 AM in reply to: _gile

wow   :smileyhappy:


i didn't think by this way , hahah ,


thanks mr _gile

Posts: 216
Registered: ‎08-24-2010
Message 14 of 14 (113 Views)

Clear Old Selection

07-01-2013 02:25 AM in reply to: Amremad

i solve 90% of my problems


no , how can i clear old selection after selection another block during selection set working




just delete new added items , but i can't access of pervious selected item

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.