I know it is old question, but maybe someone will find it useful.
Using SelectionFilter to select only opened or closed polylines (any type of polyline):
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
int polylineState = 1; // 0 - closed, 1 - open
TypedValue[] vals= new TypedValue[]
{
new TypedValue((int)DxfCode.Operator, "<or"),
// This catches Polyline object.
new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "LWPOLYLINE"),
new TypedValue(70, polylineState),
new TypedValue((int)DxfCode.Operator, "and>"),
new TypedValue((int)DxfCode.Operator, "<and"),
new TypedValue((int)DxfCode.Start, "POLYLINE"),
new TypedValue((int)DxfCode.Operator, "<or"),
// This catches Polyline2d object.
new TypedValue(70, polylineState),
// This catches Polyline3d object.
new TypedValue(70, 8|polylineState),
new TypedValue((int)DxfCode.Operator, "or>"),
new TypedValue((int)DxfCode.Operator, "and>"),
new TypedValue((int)DxfCode.Operator, "or>"),
};
SelectionFilter filter = new SelectionFilter(vals);
PromptSelectionResult prompt = ed.GetSelection(filter);
// If the prompt status is OK, objects were selected
if (prompt.Status == PromptStatus.OK)
{
SelectionSet sset = prompt.Value;
Application.ShowAlertDialog($"Number of objects selected: {sset.Count.ToString()}");
}
else
{
Application.ShowAlertDialog("Number of objects selected: 0");
}
List of all drawing entities: link 1 (older) or link 2 (newer)
In this link we see that code 70 with value of 1 is closed polyline.
And in this link we see that same applies for polyline 2d/3d, but additionaly with value 8 we define if it is 2d or 3d polyline. Values can be bitwise combined, so 8|1 means closed 3d polyline.