Hi Rishikesh. if I understand you right,
you can use selection set with layers filter:
/// <summary>
/// return selection set with filter of layers
/// </summary>
/// <param name="layers">Layers name string collection</param>
/// <returns>Selection set</returns>
static public PromptSelectionResult SelectEntitiesByLayers(stringCollection layers)
{
Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
// Build a conditional filter list so that only
// entities with the specified properties are
// selected
int i = 0;
TypedValue[] tvs = new TypedValue[1];
tvs[0] = new TypedValue((int)DxfCode.Operator, "<or");
foreach (string lay in layers)
{
//i = tvs.Length;
//TypedValue[] temp = new TypedValue[tvs.Length + 4];
TypedValue[] temp = new TypedValue[tvs.Length + 1];
if (tvs != null)
Array.Copy(tvs, temp, Math.Min(tvs.Length, temp.Length)); //VB redim preserve
tvs = temp;
//tvs[i + 1] = new TypedValue((int)DxfCode.Operator, "<and");
//tvs[i + 2] = new TypedValue((int)DxfCode.LayerName, lay);
tvs[i + 1] = new TypedValue((int)DxfCode.LayerName, lay);
//tvs[i + 3] = new TypedValue((int)DxfCode.Operator, "and>");
i++;
}
i = tvs.Length;
//TypedValue[] temp1 = new TypedValue[tvs.Length + 2];
TypedValue[] temp1 = new TypedValue[tvs.Length + 1];
if (tvs != null)
Array.Copy(tvs, temp1, Math.Min(tvs.Length, temp1.Length));
tvs = temp1;
//tvs[i + 1] = new TypedValue((int)DxfCode.Operator, "or>");
tvs[i] = new TypedValue((int)DxfCode.Operator, "or>");
SelectionFilter sf = new SelectionFilter(tvs);
PromptSelectionResult psr = ed.SelectAll(sf);
return psr;
// ed.WriteMessage("\nFound {0} entit{1}.", psr.Value.Count, (psr.Value.Count == 1 ? "y" : "ies"));
}