Page 1 of 1

How to get entities in the layer ?

Posted: 29 Mar 2020, 08:09
by windypon
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?

Re: How to get entities in the layer ?

Posted: 30 Mar 2020, 17:49
by support
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

Re: How to get entities in the layer ?

Posted: 03 Apr 2020, 04:56
by windypon
Thank you Andrey.