HI all,
i have created a stand alone application in VB.NET and opened a an AutoCAD Drawing,now i want to select the drawing (manual select on the screen)......can any one help me out with the source code....
the source code i used to open the drawing is
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
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()
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
==================================================