Page 1 of 1
Getting all the Entities of a Particular Layer
Posted: 31 Aug 2017, 09:51
by nthangaraj
How to get all the Entities in a Particular Layer.
Can we filter the Entities selected using MultipleSelect with respect to Layers?
Re: Getting all the Entities of a Particular Layer
Posted: 31 Aug 2017, 09:58
by nthangaraj
Also can we Get only the Selected type of Entities from the Selected Enities.
(Say Only Polyline or Rotated Entities)
Re: Getting all the Entities of a Particular Layer
Posted: 01 Sep 2017, 12:42
by support
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
Re: Getting all the Entities of a Particular Layer
Posted: 01 Sep 2017, 12:44
by support
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