|
发表于 2002-7-18 12:43:00
|
显示全部楼层
我写个例子,这个例子基本可用,但有些细节还须改进
Private Sub CommandButton1_Click()
UserForm1.Hide '隐藏用户窗口,以便选择CAD对象
Dim Str As String
Str = ""
Dim Ent As AcadObject, objText As AcadMText
Dim SSel As AcadSelectionSet '定义SSel为SelectionSet对象
'初始化SSel,SS1为选择集名(名称在这个例子中可任意给定)
Set SSel = ThisDrawing.SelectionSets.Add("SS1")
SSel.SelectOnScreen '提示用户选择对象
For Each Ent In SSel
With Ent
If StrComp(.ObjectName, "AcDbMText") = 0 Or StrComp(.ObjectName, "AcDbText") = 0 Then
'若Ent为AcDbMText或AcDbText文本类型
If IsNumeric(.TextString) Then '若Ent内容为数字
Str = Str & .TextString & " "
End If
End If
End With
Next Ent
TextBox1.Text = Str
UserForm1.Show '重新显示用户窗口
End Sub |
|