SelectionSet or Filter for Entities

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
slingblade
Posts: 16
Joined: 31 May 2010, 13:33

SelectionSet or Filter for Entities

Post by slingblade » 03 Jun 2010, 03:40

Hi,

Is there a way to apply a filter to return a group of entities, much like the AutoCAD SelectionSet method?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: SelectionSet or Filter for Entities

Post by support » 03 Jun 2010, 15:48

Hello.
You can use own simple condition, for example:

Code: Select all

      CADEntityCollection co = new CADEntityCollection();
      for (int i = 0; i < this.cadImage.Converter.Entities.Count; i++)
      {
            CADEntity ent = this.cadImage.Converter.Entities[i];
            if (ent.EntType == EntityType.Ellipse)
                  co.Add(ent);
      }
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

slingblade
Posts: 16
Joined: 31 May 2010, 13:33

Re: SelectionSet or Filter for Entities

Post by slingblade » 04 Jun 2010, 01:21

Hi,

So iterating over the entire collection of entities is the only option?

I ask because I can see times where there might by 100,000 entities or more and having to iterate through each one might be an issue.

Is the underlying structure of a dwg a database? If it is could you not have a method to query the db directly? I can only assume this is how AutoCAD selection sets work...

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: SelectionSet or Filter for Entities

Post by support » 04 Jun 2010, 14:08

Hello.
The code sample was an example of creating collection of entities with some specific characteristic (ellipse entities). If I understand correctly the filling of selection set object in AutoCAD is similar proccess, for example by group codes. The necessity of iterating over collection depends on your task. Selection can be realized by handle or visually.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

slingblade
Posts: 16
Joined: 31 May 2010, 13:33

Re: SelectionSet or Filter for Entities

Post by slingblade » 04 Jun 2010, 17:45

Hi,

Maybe if I'm more specific you can tell me if it can do this.

Say I have 100,000 lines in my dwg and 200,000 block references for a total of 300,000 entities in my drawing (lets not even talk about points).

I want to be able to quickly select all lines on layer 123, that are red and have a linetype of dot.

What would be great would be to query the data directly from the drawing if it has an underlying database, I don't know enough about dwg's to say for sure I am just speculating, but it makes since to me that it's built on a relational database.
For example for regular SQL: SELECT ALL Lines FROM LineTable WHERE Layer ="Red" AND Linetype = "dot";.

Let the database do the work it's designed to do, rather that iterating over all 300,000 entities, first checking if its a Line then check the layer name and linetype AND so on.

AutoCAD selectionset's are like the first example in that I set some group codes and logical operators (less than, greater than, equal to etc...) to form a quasi query. Selection sets are much much faster that trying to iterate over every entity in the drawing.

I don't know if you guys have any features/abilities to get at data like that or not?

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: SelectionSet or Filter for Entities

Post by support » 09 Jun 2010, 16:22

Hello Scott.
The AutoCAD DWG/DXF format structure is a database itself. Each entity from AutoCAD drawing has its own unique identifier - the handle. The handle is the key to AutoCAD drawing's data. However, selection of a set of entities that have some specific property (like color or type) require Iterating.
AutoCAD selectionset's are like the first example in that I set some group codes and logical operators (less than, greater than, equal to etc...) to form a quasi query. Selection sets are much much faster that trying to iterate over every entity in the drawing.
yes, but you need create the selection set before use it. And this proccess is similar to code for the CAD Import .NET.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply