你好!不知怎样用VBA读取CAD中的文本内容或CAD中的表格内容?
展开全部
Private Sub MyList()
Dim ssetObj As Object 'AcadSelectionSet
Dim i As Long
corner1(0) = 0: corner1(1) = 0: corner1(2) = 0
corner2(0) = 1000: corner2(1) = 1000: corner2(2) = 0
On Error GoTo Err1
' Create the selection set
If Not IsNull(AcadDoc.SelectionSets.Item("SSET")) Then
Set ssetObj = AcadDoc.SelectionSets.Item("SSET")
ssetObj.Delete
End If
Err1:
Set ssetObj = AcadDoc.SelectionSets.Add("SSET")
Dim mode As Integer
Dim minPoint, MaxPoint
i = 0
mode = 1 'acSelectionSetCrossing
ssetObj.Select mode, corner1, corner2
Dim ENT As Object
For Each ENT In ssetObj
If ENT.EntityName = "AcDbText" Then
i = i + 1
Cells(i, 1) = ENT.TextString
End If
Next ENT
End Sub
Dim ssetObj As Object 'AcadSelectionSet
Dim i As Long
corner1(0) = 0: corner1(1) = 0: corner1(2) = 0
corner2(0) = 1000: corner2(1) = 1000: corner2(2) = 0
On Error GoTo Err1
' Create the selection set
If Not IsNull(AcadDoc.SelectionSets.Item("SSET")) Then
Set ssetObj = AcadDoc.SelectionSets.Item("SSET")
ssetObj.Delete
End If
Err1:
Set ssetObj = AcadDoc.SelectionSets.Add("SSET")
Dim mode As Integer
Dim minPoint, MaxPoint
i = 0
mode = 1 'acSelectionSetCrossing
ssetObj.Select mode, corner1, corner2
Dim ENT As Object
For Each ENT In ssetObj
If ENT.EntityName = "AcDbText" Then
i = i + 1
Cells(i, 1) = ENT.TextString
End If
Next ENT
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询