- 积分
- 4493
- 明经币
- 个
- 注册时间
- 2011-11-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2011-11-11 17:28:10
|
显示全部楼层
我也是一个新手,不过你可以看看这个程序,希望对你有所帮助
Private Sub CommandButton1_Click()
Dim ssetobj As AcadSelectionSet
Dim fType As Variant
Dim fData As Variant
On Error Resume Next
Set ssetobj = AcadApplication.ActiveDocument.SelectionSets.Add("jiaoliexu")
AppActivate AcadApplication.Caption
UserForm1.hide
BuildFilter fType, fData, -4, "<or", 0, "text", 0, "mtext", -4, "or>"
'在第二个-4前加一个“0, "dimension",”表示标注内容
ssetobj.SelectOnScreen fType, fData
Dim pickedobjs As AcadEntity
For Each pickedobjs In ssetobj
pickedobjs.color = acRed
pickedobjs.Update
Next
ssetobj.Delete
End Sub
Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
'ParamArray 用于过程最后的一个参数,表示该参数是包含任意个数元素的数组(Variant 类型)
'ParamArray 不能与 ByVal、ByRef或 Optional 一起使用。
Dim fType() As Integer, fData()
Dim index As Long, i As Long
index = LBound(gCodes) - 1
For i = LBound(gCodes) To UBound(gCodes) Step 2
index = index + 1
ReDim Preserve fType(0 To index)
ReDim Preserve fData(0 To index)
fType(index) = CInt(gCodes(i))
fData(index) = gCodes(i + 1)
Next
typeArray = fType: dataArray = fData
End Sub |
|