Filter Pickfirst Selectionset

Filter Pickfirst Selectionset

SRSDS
Advisor Advisor
1,149 Views
3 Replies
Message 1 of 4

Filter Pickfirst Selectionset

SRSDS
Advisor
Advisor

Hi,

 

I want to use the pickfirst (UsePickSet) selection then filter that selection to make sure I'm only modifying a certain dynamic block.

I have a selection filter set up for the named dynamic block (and use it for the ed.GetSelection method) but I don't know how to apply it to the returned pickfirst selection.

Is this possible?

0 Likes
Accepted solutions (1)
1,150 Views
3 Replies
Replies (3)
Message 2 of 4

SRSDS
Advisor
Advisor

It was easy enough to step through all the selected elements checking block names and adding them to an Idcollection.

Maybe I Just wondered if there was a more elegant way like the getselection filter.

0 Likes
Message 3 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

With CommandFlags.UsePickSet, the selection filter passed to the EditorGetSelection() method is automatically applied to the active selection if any.

 

You can with try this little snippet both ways: selecting blocks and other entites before or after launching the TEST command.

 

        [CommandMethod("Test", CommandFlags.UsePickSet)]
        public void Test()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            TypedValue[] filter = { new TypedValue(0, "INSERT") };
            PromptSelectionResult psr = ed.GetSelection(new SelectionFilter(filter));
            if (psr.Status != PromptStatus.OK) return;
using (Transaction tr = db.TransactionManager.StartTransaction()) { foreach (SelectedObject obj in psr.Value) { BlockReference br = (BlockReference)tr.GetObject(obj.ObjectId, OpenMode.ForWrite); br.Color = Color.FromColorIndex(ColorMethod.ByAci, 30); } tr.Commit(); } }

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 4

SRSDS
Advisor
Advisor

That simplifies things.

 

I was following an example I found which was different and made things slightly more complicated.

http://through-the-interface.typepad.com/through_the_interface/2006/09/using_the_pickf.html

 

Thankyou

0 Likes