2012년 3월 6일 화요일

다중 필터 Specify Multiple Criteria in a Selection Filter


using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;

[CommandMethod("FilterBlueCircleOnLayer0")]
public static void FilterBlueCircleOnLayer0()
{
  // Get the current document editor
  Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor;

  // Create a TypedValue array to define the filter criteria
  TypedValue[] acTypValAr = new TypedValue[3];
  acTypValAr.SetValue(new TypedValue((int)DxfCode.Color, 5), 0);
  acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "CIRCLE"), 1);
  acTypValAr.SetValue(new TypedValue((int)DxfCode.LayerName, "0"), 2);
  //필터링 내용을 TypedValue[]의 인스턴스에 지정한다.
 
  // Assign the filter criteria to a SelectionFilter object
  SelectionFilter acSelFtr = new SelectionFilter(acTypValAr);

  //SelectionFilte인스턴스를 만들고 성정한 필터값 배열을 이용해서 초기화 한다.

  // Request for objects to be selected in the drawing area
  PromptSelectionResult acSSPrompt;
  acSSPrompt = acDocEd.GetSelection(acSelFtr);
  //선택필터값을 프롬프트 인스턴스에 넘겨프롬프트에 출력.???

  // If the prompt status is OK, objects were selected
  if (acSSPrompt.Status == PromptStatus.OK)
  {
      SelectionSet acSSet = acSSPrompt.Value;

      Application.ShowAlertDialog("Number of objects selected: " +
                                  acSSet.Count.ToString());
  }
  else
  {
      Application.ShowAlertDialog("Number of objects selected: 0");
  }
}

원 이면서 레이어가 "0"인 객체를 필터링

출처
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

댓글 없음 :

댓글 쓰기