I'm using the following function to give me a selection set of Block refs on a specific layer. AutoCADDrawingObjectName.BlockReference returns the text "INSERT".
But it's returning an error warning (no code that I can pick up) for the selectionSetResult.Status value and Null for the value, when I know that there are Block refs for the layer I'm asking for.
public static SelectionSet GetBlockRefOnLayerSelectionSet(string LayerName)
{
Document thisDrawing;
SelectionSet selectionSet = null;
PromptSelectionResult selectionSetResult;
TypedValue[] typedArray = new TypedValue[2];
SelectionFilter selectionFilter;
try
{
thisDrawing = GetDocument();
Editor editor = thisDrawing.Editor;
typedArray.SetValue(new TypedValue((int)DxfCode.Start, AutoCADDrawingObjectName.BlockReference), 0);
typedArray.SetValue(new TypedValue((int)DxfCode.LayerName, LayerName), 1);
selectionFilter = new SelectionFilter(typedArray);
selectionSetResult = editor.SelectAll(selectionFilter);
if (selectionSetResult.Value != null)
{
selectionSet = selectionSetResult.Value;
}
}
catch (Exception ex)
{
MessageBox.Show("AutoCADUtility.GetBlockRefOnLayerSelectionSet : " + ex.Message, MessageHeadings.ExceptionError);
}
return selectionSet;
}
I can't help feeling that the Editor.SelectAll instruction is wrong. The COM AcadSelectionSet class allows us to create global selection sets with the .Select method, but I cannot find the equivalent.
Can anyone see what I'm doing wrong here?
Regards, Paul