Home AutoCad VB Export Polyline Coordinates to Textfile
20 | 05 | 2012
This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade

Export Polyline Coordinates to Textfile PDF Print E-mail
User Rating: / 1
PoorBest 
Tutorials

This code exports all polyline coordinates to a textfile located at C:\TEST.txt.

Show/Hidden vbnet code

View source
 
 
	Public Sub WriteAllPolylinesToFile(strFilename As String)
 
	Dim objSelectionSet As AcadSelectionSet
 
	Dim intGroupCode(0) As Integer
 
	Dim varDataCode(0) As Variant
 
	Dim objAcadPoly As AcadLWPolyline
 
	Dim lngL As Long
 
 
 
	On Error Resume Next
 
 
 
	'do Lightweight polylines
 
	intGroupCode(0) = 0
 
	varDataCode(0) = "LWPolyline"
 
 
 
	ThisDrawing.SelectionSets.Item("Poly").Delete
 
 
 
	If Err Then Err.Clear
 
 
 
	'create a selection of all lightweight polylines
 
	Set objSelectionSet = ThisDrawing.SelectionSets.Add("Poly")
 
	objSelectionSet.Select acSelectionSetAll, , , intGroupCode, varDataCode
 
 
 
	'write the polyline vertices to file
 
	Open strFilename For Append Access Write As #10
 
	Write #10, "Polyline vertices"
 
	'go through each polyline object
 
	For Each objAcadPoly In objSelectionSet
 
	For lngL = 0 To UBound(objAcadPoly.Coordinates)
 
	Write #10, objAcadPoly.Coordinates(lngL)
 
	Next lngL
 
	Next objAcadPoly
 
	Close #10
 
 
 
	If Err Then
 
	Kill strFilename
 
	MsgBox "There were errors, no file created!"
 
	End If
 
	End Sub
 
 
 
	Sub TestExportFunction()
 
 
 
	WriteAllPolylinesToFile "C:\TEST.txt"
 
	End Sub

Attachments:
FileDescriptionFile sizeDownloads
Download this file (Export Coordinates.dvb)Export Coordinates.dvb 32 Kb1101
 

Comments   

 
0 #1 Guest 2011-12-21 20:53
Dear Master:
I tried the "WriteAllPolyli nesToFile", there the first string "Public Sub WriteAllPolylin esToFile(strFil ename As String)" looks like have to set as "Public Sub WriteAllPolylin esToFile() Dim strFilename As String". After excuted, it report en error "There were errors, no file created!" How can I fixed?
I also tried the "Export Coordinates.dvd ". The report file is created but there is not any coordinates date or any information inside!!! but no error report was showup with this one. What is wrong?
My system is;
Windows7 32 bit.
Autocad 2012
Microsoft excel 2007.
I tried only drawed a cross with polyline onto the layer 0 then I ran the VBA.
Could you please give me any idea? Thanks a lot.
Quote
 

Add comment


Security code
Refresh

This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade