- Imports Autodesk.AutoCAD.RuntimeImports Autodesk.AutoCAD.ApplicationServicesImports Autodesk.AutoCAD.DatabaseServicesImports Autodesk.AutoCAD.EditorInput <CommandMethod("FilterBlueCircleOnLayer0")> _Public Sub FilterBlueCircleOnLayer0() '' 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.Color, 5), 0) acTypValAr.SetValue(New TypedValue(DxfCode.Start, "CIRCLE"), 1) acTypValAr.SetValue(New TypedValue(DxfCode.LayerName, "0"), 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 IfEnd Sub
好好看帮助,自己去调试吧,开发人员帮助 |