hi all,
i have a designed a form to open an autocad drawing
......now i want to make a manual selection in the drawing and select all the text in the drawing and then display the text in a listbox.....the code to open the autocad drawing is
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.AutoCAD.DatabaseServices
Imports dbtransman = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Public Class Form1
Public WithEvents acadApp As Autodesk.AutoCAD.Interop.AcadApplication
Dim acadDoc As Autodesk.AutoCAD.Interop.AcadDocument
Public Sub GetAcadApplication()
Try
acadApp = GetObject(, "AutoCAD.Application.16.2")
acadApp.Visible = True
Catch
Try
acadApp = CreateObject("AutoCAD.Application.16.2")
acadApp.Visible = True
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical)
Exit Sub
End Try
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles seldwg.Click
Dim opdlg As New OpenFileDialog()
opdlg.InitialDirectory = "d:\"
opdlg.Filter = "dwg files (*.dwg)|*.dwg"
opdlg.FilterIndex = 2
opdlg.RestoreDirectory = True
opdlg.Multiselect = False
If opdlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim count As Integer = opdlg.FileNames.Length.ToString
Dim i
For i = 0 To count - 1
ListBox1.Items.Add(opdlg.FileNames.GetValue(i).ToString)
Next
End If
End Sub
Sub ProcessDirectory(ByVal targetDirectory As String)
Dim fileEntries As String() = System.IO.Directory.GetFiles(targetDirectory)
Dim fileName As String
For Each fileName In fileEntries
If LCase(System.IO.Path.GetExtension(fileName)) = ".dwg" Then
ListBox1.Items.Add(fileName)
End If
Next fileName
Dim subdirectoryEntries As String() = System.IO.Directory.GetDirectories(targetDirectory)
Dim subdirectory As String
For Each subdirectory In subdirectoryEntries
ProcessDirectory(subdirectory)
Next subdirectory
End Sub
Sub ProcessDwg(ByVal ThisDwg As String)
acadDoc.Application.Documents.Open(ThisDwg)
acadDoc = acadApp.ActiveDocument
'acadApp.ZoomExtents()
'Add code to do something with the drawing here.
'code....
'code....
'code....
'acadDoc.Wbloc(False, ThisDwg)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles open.Click
If ListBox1.Items.Count < 1 Then
MsgBox("No Drawing Have Been Selected To Open")
End If
Call GetAcadApplication()
Dim i
Dim r As Integer = 0
Dim dwgname As String = ""
For i = 0 To ListBox1.Items.Count - 1
acadDoc = acadApp.ActiveDocument
acadDoc = acadApp.Documents.Add
dwgname = ListBox1.Items.Item(0)
ProcessDwg(dwgname)
ListBox1.Items.RemoveAt(0)
r = r + 1
Next
End Sub
CAN ANYONE HELP ME