Getting all the Entities of a Particular Layer

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
nthangaraj
Posts: 19
Joined: 31 Aug 2017, 09:47

Getting all the Entities of a Particular Layer

Post by nthangaraj » 31 Aug 2017, 09:51

How to get all the Entities in a Particular Layer.
Can we filter the Entities selected using MultipleSelect with respect to Layers?

nthangaraj
Posts: 19
Joined: 31 Aug 2017, 09:47

Re: Getting all the Entities of a Particular Layer

Post by nthangaraj » 31 Aug 2017, 09:58

Also can we Get only the Selected type of Entities from the Selected Enities.
(Say Only Polyline or Rotated Entities)

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

Re: Getting all the Entities of a Particular Layer

Post by support » 01 Sep 2017, 12:42

Hello,
To get all entities in one certain layer, use the following code:

Code: Select all

public List<CADEntity> GetAllLayerEntities(CADImage img, string layerName)
        {
            List<CADEntity> ResList = new List<CADEntity>();
            for (int i = 0; i < img.Converter.Entities.Count; i++)
            {
                CADEntity ent = img.Converter.Entities[i];
                if (ent.Layer.Name == layerName)
                {
                    ResList.Add(ent);
                }
            }
            return ResList;
        }
Also, it is possible to filter entities selected by MultipleSelect according to layers:

Code: Select all

 public List<CADEntity> GetSelectedByLayer(CADImage img, string layerName)
        {
            List<CADEntity> ResList = new List<CADEntity>();
            for (int i = 0; i < img.SelectedEntities.Count; i++)
            {
                CADEntity ent = img.SelectedEntities[i];
                if (ent.Layer.Name == layerName)
                {
                    ResList.Add(ent);
                }
            }
            return ResList;
        }

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

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

Re: Getting all the Entities of a Particular Layer

Post by support » 01 Sep 2017, 12:44

This is how you can get only the selected type of entities from the selected entities:

Code: Select all

 public List<CADEntity> GetSelectedByType(CADImage img,EntityType type)
        {
            List<CADEntity> ResList = new List<CADEntity>();
            for (int i = 0; i < img.SelectedEntities.Count; i++)
            {
                CADEntity ent = img.SelectedEntities[i];
                if (ent.EntType==type)
                {
                    ResList.Add(ent);
                }
            }
            return ResList;
        }
Catherine
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply