|
Tutorials
|
|
This code exports all polyline coordinates to a textfile located at C:\TEST.txt.
Show/Hidden vbnet code 
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
|
Comments
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.
RSS feed for comments to this post