How to get entities in the layer ?

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
windypon
Posts: 2
Joined: 29 Mar 2020, 08:03

How to get entities in the layer ?

Post by windypon » 29 Mar 2020, 08:09

I'd like to get entities in the layer, but CADLayer.Entities is always null.

... and, this forum seach rejects my search "How to get entities in layer" because of too common words.
Some good way?

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

Re: How to get entities in the layer ?

Post by support » 30 Mar 2020, 17:49

Hi,

You can get the entities in one certain layer using 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;
        }
You can find out more in the following post: viewtopic.php?f=15&t=4906&p=13724&hilit=layers#p13724

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

windypon
Posts: 2
Joined: 29 Mar 2020, 08:03

Re: How to get entities in the layer ?

Post by windypon » 03 Apr 2020, 04:56

Thank you Andrey.

Post Reply