複数の選択条件を指定すると、AutoCAD はそれぞれのすべての条件を満たすオブジェクトだけを選択します。他の方法で条件を設定することもできます。数値項目では、関係演算を指定できます(たとえば、円の半径は、5.0 以上のものを選択)。また、すべての項目で論理演算を指定できます(たとえば、Text または MText オブジェクトを選択)。
選択フィルタの関係演算子を指定するには、DXF コード -4 または定数 DxfCode.Operator を使用します。演算子は文字列として表されます。利用可能な関係演算子を次の表に示します。
選択セット フィルタ リストの関係演算子 |
|
---|---|
operator |
説 明 |
"*" |
すべてのもの(常に真) |
"=" |
等しい |
"!=" |
等しくない |
"/=" |
等しくない |
"<>" |
等しくない |
"<" |
より小さい |
"<=" |
より小さいか等しい |
">" |
より大きい |
">=" |
より大きいか等しい |
"&" |
ビット方式の AND(整数グループのみ) |
"&=" |
ビット方式のマスクが等しい(整数グループのみ) |
選択フィルタの中の論理演算子も、グループ コード -4 または定数 DxfCode.Operator で表し、演算子は文字列です。演算子は必ず対で指定します。論理演算の開始を表す演算子は、始めに小なり記号(<)を伴い、論理演算の終了を表す演算子は、終わりに大なり記号(>)を伴います。次の表は、選択セットのフィルタ処理の中で現れる論理演算子の一覧です。
選択セット フィルタ リストの論理演算子 |
||
---|---|---|
開始演算子 |
囲むことのできるオペランドの数 |
終了演算子 |
"<AND" |
1 つ以上のオペランド |
"AND>" |
"<OR" |
1 つ以上のオペランド |
"OR>" |
"<XOR" |
2 つのオペランド |
"XOR>" |
"<NOT" |
1 つのオペランド |
"NOT>" |
次の例は、半径が 5.0 以上の円を選択します。
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput <CommandMethod("FilterRelational")> _ Public Sub FilterRelational() '' Get the current document editor Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor '' Create a TypedValue array to define the filter criteria Dim acTypValAr(2) As TypedValue acTypValAr.SetValue(New TypedValue(DxfCode.Start, "CIRCLE"), 0) acTypValAr.SetValue(New TypedValue(DxfCode.Operator, ">="), 1) acTypValAr.SetValue(New TypedValue(40, 5), 2) '' Assign the filter criteria to a SelectionFilter object Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr) '' Request for objects to be selected in the drawing area Dim acSSPrompt As PromptSelectionResult acSSPrompt = acDocEd.GetSelection(acSelFtr) '' If the prompt status is OK, objects were selected If acSSPrompt.Status = PromptStatus.OK Then Dim acSSet As SelectionSet = acSSPrompt.Value Application.ShowAlertDialog("Number of objects selected: " & _ acSSet.Count.ToString()) Else Application.ShowAlertDialog("Number of objects selected: 0") End If End Sub
using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; [CommandMethod("FilterRelational")] public static void FilterRelational() { // 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.Start, "CIRCLE"), 0); acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, ">="), 1); acTypValAr.SetValue(new TypedValue(40, 5), 2); // Assign the filter criteria to a SelectionFilter object SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); // 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"); } }
Sub FilterRelational() Dim sset As AcadSelectionSet Dim FilterType(2) As Integer Dim FilterData(2) As Variant Set sset = ThisDrawing.SelectionSets.Add("SS1") FilterType(0) = 0: FilterData(0) = "Circle" FilterType(1) = -4: FilterData(1) = ">=" FilterType(2) = 40: FilterData(2) = 5# sset.SelectOnScreen FilterType, FilterData MsgBox "Number of objects selected: " & sset.Count ' Remove the selection set at the end sset.Delete End Sub
次の例は、Text と MText オブジェクトのいずれかを選択するものです。
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput <CommandMethod("FilterForText")> _ Public Sub FilterForText() '' Get the current document editor Dim acDocEd As Editor = Application.DocumentManager.MdiActiveDocument.Editor '' Create a TypedValue array to define the filter criteria Dim acTypValAr(3) As TypedValue acTypValAr.SetValue(New TypedValue(DxfCode.Operator, "<or"), 0) acTypValAr.SetValue(New TypedValue(DxfCode.Start, "TEXT"), 1) acTypValAr.SetValue(New TypedValue(DxfCode.Start, "MTEXT"), 2) acTypValAr.SetValue(New TypedValue(DxfCode.Operator, "or>"), 3) '' Assign the filter criteria to a SelectionFilter object Dim acSelFtr As SelectionFilter = New SelectionFilter(acTypValAr) '' Request for objects to be selected in the drawing area Dim acSSPrompt As PromptSelectionResult acSSPrompt = acDocEd.GetSelection(acSelFtr) '' If the prompt status is OK, objects were selected If acSSPrompt.Status = PromptStatus.OK Then Dim acSSet As SelectionSet = acSSPrompt.Value Application.ShowAlertDialog("Number of objects selected: " & _ acSSet.Count.ToString()) Else Application.ShowAlertDialog("Number of objects selected: 0") End If End Sub
using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; [CommandMethod("FilterForText")] public static void FilterForText() { // Get the current document editor Editor acDocEd = Application.DocumentManager.MdiActiveDocument.Editor; // Create a TypedValue array to define the filter criteria TypedValue[] acTypValAr = new TypedValue[4]; acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "<or"), 0); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "TEXT"), 1); acTypValAr.SetValue(new TypedValue((int)DxfCode.Start, "MTEXT"), 2); acTypValAr.SetValue(new TypedValue((int)DxfCode.Operator, "or>"), 3); // Assign the filter criteria to a SelectionFilter object SelectionFilter acSelFtr = new SelectionFilter(acTypValAr); // 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"); } }
Sub FilterForText() Dim sset As AcadSelectionSet Dim FilterType(3) As Integer Dim FilterData(3) As Variant Set sset = ThisDrawing.SelectionSets.Add("SS1") FilterType(0) = -4: FilterData(0) = "<or" FilterType(1) = 0: FilterData(1) = "TEXT" FilterType(2) = 0: FilterData(2) = "MTEXT" FilterType(3) = -4: FilterData(3) = "or>" sset.SelectOnScreen FilterType, FilterData MsgBox "Number of objects selected: " & sset.Count ' Remove the selection set at the end sset.Delete End Sub