2017년 2월 20일 월요일

[C#, Autodesk.NET] To get ObjectIdCollection of all entities in layer.

private ObjectIdCollection GetEntitiesOnLayer(string layerName)
{
    Document doc = GetDocument();
    Editor ed = GetEditor();

    // Build a filter list so that only entities
    // on the specified layer are selected
    TypedValue[] tvs = new TypedValue[1] { new TypedValue((int)DxfCode.LayerName, layerName) };
    SelectionFilter sf = new SelectionFilter(tvs);
    PromptSelectionResult psr = ed.SelectAll(sf);

    if (psr.Status == PromptStatus.OK)
        return new ObjectIdCollection(psr.Value.GetObjectIds());
    else
        return new ObjectIdCollection();
}

댓글 없음:

댓글 쓰기