Help using SelectionFilter

Help using SelectionFilter

Anonymous
Not applicable
972 Views
5 Replies
Message 1 of 6

Help using SelectionFilter

Anonymous
Not applicable
Hi all;

Sorry if this is a basic question, but I can't for the life of me figure this out! I am writing my ACAD app in C# and I want to be able to select all objects in the currently open drawing that are blocks of a particular name. I have been trying to use selection filters for this, but I am not having any luck.

I have attached my code below; could someone perhaps point me in the write direction? I always get a status ERROR when I run this.
...
TypedValue[] value = { new TypedValue(2, "PANEL") };
SelectionFilter filter = new SelectionFilter(value);
PromptSelectionResult selectAll = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.SelectAll(filter);
...

Here is a listing of one of the blocks in my drawing, for reference:


"BLOCK REFERENCE Layer: "GR-SK-AR"
Space: Model space
Handle = d34
Block Name: "PANEL"
Anonymous Name: "*U10"
at point, X= 469.0271 Y=1062.0000 Z= 0.0000"

Any help or guidance would be greatly appreciated.

Thanks!
0 Likes
973 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
You need the DXF 0 entity type = INSERT in addition to the block name

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6146641@discussion.autodesk.com...
Hi all; Sorry if this is a basic question, but I can't for the life of me
figure this out! I am writing my ACAD app in C# and I want to be able to
select all objects in the currently open drawing that are blocks of a
particular name. I have been trying to use selection filters for this, but I
am not having any luck. I have attached my code below; could someone perhaps
point me in the write direction? I always get a status ERROR when I run
this. ... TypedValue[] value = { new TypedValue(2, "PANEL") };
SelectionFilter filter = new SelectionFilter(value); PromptSelectionResult
selectAll =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.SelectAll(filter);
... Here is a listing of one of the blocks in my drawing, for reference:
"BLOCK REFERENCE Layer: "GR-SK-AR" Space: Model space Handle = d34 Block
Name: "PANEL" Anonymous Name: "*U10" at point, X= 469.0271 Y=1062.0000 Z=
0.0000" Any help or guidance would be greatly appreciated. Thanks!
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks for the reply. I changed my code to the following:

TypedValue[] value = { new TypedValue(0, "INSERT"), new TypedValue(2, "PANEL") };

and still received the error. I am wondering at this point about the block name. I am assuming that the block name in the listing I pasted above (from the "LS" command) is the same as the block name referred to in the DxfCode 2 - am I right in that?

Any other suggestions or pointers greatly appreciated!
0 Likes
Message 4 of 6

Anonymous
Not applicable
After going back and looking at your original post I see
that the block is dynamic block.

You can't filter for insertions of them because they are
represented in the drawing by anonymous blocks. In the
listing you showed, the 'Anonymous Name: "*U10"' is the
actual name of the block.

You can do this in one of several ways, both of them are
fairly complicated, and they've been covered here in the
pasts, so you should search the newsgroups for pointers
on how to do this.

Of course, we should all give Autodesk a big pat on the
back for completely bungling this one, by failing to recognize
the obvious functional requirement, and the impedement it
imposes on their dear beloved AutoCAD customers.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6146682@discussion.autodesk.com...
Thanks for the reply. I changed my code to the following: TypedValue[] value
= { new TypedValue(0, "INSERT"), new TypedValue(2, "PANEL") }; and still
received the error. I am wondering at this point about the block name. I am
assuming that the block name in the listing I pasted above (from the "LS"
command) is the same as the block name referred to in the DxfCode 2 - am I
right in that? Any other suggestions or pointers greatly appreciated!
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks again for the reply.

I already have a solution in place that iterates through all the objects found in a "SelectAll" operation and finds the blocks I am looking for. I was hoping that filtering would provide a better solution that going through all the entities in the drawing, but I guess that's not the case.

While we're on the subject, can I use filtering to retrieve any TEXT or MTEXT objects in the drawing? I am assuming I can since they aren't dynamic blocks.
0 Likes
Message 6 of 6

Anonymous
Not applicable
Yes, you can by using the entity type's name with the
DXF 0 filter item. You can also include multiple types
seperated by commas:

new TypedValue( 0, "TEXT,MTEXT" )

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm


wrote in message news:6146690@discussion.autodesk.com...
Thanks again for the reply. I already have a solution in place that iterates
through all the objects found in a "SelectAll" operation and finds the
blocks I am looking for. I was hoping that filtering would provide a better
solution that going through all the entities in the drawing, but I guess
that's not the case. While we're on the subject, can I use filtering to
retrieve any TEXT or MTEXT objects in the drawing? I am assuming I can since
they aren't dynamic blocks.
0 Likes