本帖最后由 zzyong00 于 2015-4-19 14:32 编辑
- Private Sub SelectLots(ByVal Ssetname As String, _
- ByVal objName As String, _
- Optional strPrompt As String = "请选择单行文本,可以框选" & vbCrLf)
- 'Ssetname 新建选择集的名
- 'objName 要选择对象的名,可以文字对象,也可以是直线或其它任何acad实体
- 'strPrompt 选择时提示的文字
- Dim sSetObj As AcadSelectionSet, flag As Boolean
- For Each sSetObj In ThisDrawing.SelectionSets
- If sSetObj.name = Ssetname Then
- flag = True
- Exit For
- End If
- Next
- If flag Then sSetObj.Delete '创建集合,如集存在,则删除,新建
- Set sSetObj = ThisDrawing.SelectionSets.Add(Ssetname)
- Dim gpCode(0) As Integer
- Dim dataValue(0) As Variant
- gpCode(0) = 0
- dataValue(0) = objName
- Dim groupCode As Variant, dataCode As Variant
- groupCode = gpCode
- dataCode = dataValue
- ThisDrawing.Utility.Prompt strPrompt
- sSetObj.SelectOnScreen groupCode, dataCode
- End Sub
- Sub kk()
- Dim myset As AcadSelectionSet
- Dim obj As AcadObject
- SelectLots "drawletter", "*POLYLINE"
- Set myset = ThisDrawing.SelectionSets("drawletter")
- if myset.Count=0 then exit sub
- For Each obj In myset
- Debug.Print obj.ObjectName
- Next obj
- myset.Item(0).Highlight True
- End Sub
|