给你贴个小程序,看看里面的用法

- [FONT=courier new]
- Private Sub useLispToGetSelectionSet()
-
- ' Declare variables
- Dim ssnew As AcadSelectionSet
- Dim setcount As Integer
- Dim xDel As Integer
- ' Remove all selectionsets, include this
- ' if the SelectionsSet named Layout1 already exists
- setcount = ThisDrawing.SelectionSets.Count
- For xDel = 0 To setcount - 1
- ThisDrawing.SelectionSets.Item(xDel).Delete
- Next xDel
-
- ' Make a new selection set
- Set ssnew = ThisDrawing.SelectionSets.Add("Layout1")
-
- ' Use SendCommand to send a Lisp routine to put the objects
- ' in Model space in a selection set, you can change "Model" to the
- ' name of the Layout to put the entities on that layout in the
- ' selection set
- ThisDrawing.SendCommand ("(Setq ss1(ssget " & Chr(34) & "X" & Chr(34) & _
- "'((410 . " & Chr(34) & "Model" & Chr(34) & "))))" & vbCr)
-
- ' Make the selection set ssnew the last selection set
- ' created above
- ssnew.Select acSelectionSetPrevious
-
- ' Display a message box reporting the number of entities
- ' in the Selection set
- MsgBox "Number of entities in ssnew: " & ssnew.Count
-
- ' Delete the Seletion Set
- ssnew.Delete
- End Sub[/FONT]
|