Join online Course on AutoCAD VBA Programming
Following is the VBA code to extract details of Text in an AutoCAD Drawing.
Sub ExtractDetailsOfText()
Open “E:ExtractedDetails.txt” For Output As 1
Dim x As Double, y As Double, z As Double
Dim XLnCADObject As AcadObject
Dim XLnCADText As AcadText
Dim XLnCADSelection As AcadSelectionSet
MsgBox “Select Objects”, , “XL n CAD”
On Error Resume Next
Set XLnCADSelection = ThisDrawing.SelectionSets.Add(“XLnCAD_SelectionSet”)
Set XLnCADSelection = ThisDrawing.SelectionSets(“XLnCAD_SelectionSet”)
XLnCADSelection.SelectOnScreen
For Each XLnCADObject In ThisDrawing.SelectionSets(“XLnCAD_SelectionSet”)
If XLnCADObject.ObjectName = “AcDbText” Then
Set XLnCADText = XLnCADObject
x = XLnCADText.InsertionPoint(0)
y = XLnCADText.InsertionPoint(1)
z = XLnCADText.InsertionPoint(2)
Print #1, x; y; z; XLnCADObject.TextString
End If
Next
Close (1)
XLnCADSelection.Clear
End Sub