.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

extracting selected text

5 REPLIES 5
Reply
Message 1 of 6
rocky16
353 Views, 5 Replies

extracting selected text

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
5 REPLIES 5
Message 2 of 6
NathTay
in reply to: rocky16

Are you developing a stand alone application or an application to be loaded into AutoCAD.

Regards - Nathan
Message 3 of 6
rocky16
in reply to: rocky16

ya its a stand alone application
Message 4 of 6
rocky16
in reply to: rocky16

hello,
ya its a stand alone application......
regards
rocky
Message 5 of 6
Anonymous
in reply to: rocky16

Try to remove Acad version
Change
("AutoCAD.Application.16.2")
on
("AutoCAD.Application")

Hope that helps

~'J'~
Message 6 of 6
Anonymous
in reply to: rocky16

You can't use the AutoCAD managed API
from a standalone application, only from
a DLL that's NETLOADed into AutoCAD.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5555890@discussion.autodesk.com...
hello,
ya its a stand alone application......
regards
rocky

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost