Son of the Polylinethingy

A few weeks ago, I posted a little macro that extracted the XYZ values for polylines and saved them out to a txt file. This allowed you to then build a surface with a boatload of data with very little overhead in your actual dwg file. I tested it on 975,000 points and the surface built in less than a minute on a Cannon beta.

Well, now here comes something even better. Our good friend Rob Todd at Autodesk one-upped me and sent this little routine that creates an FLT file from polylines. With his permission, I’ve posted the routine. Read on to find out how it works, what the dvb module name is, and for an example of the output.

Download the DVB file called “Breakline (flt) File Generator.dvb” (the attached zip contains the original polylinethingy.dvb too). This macro creates a FLT file that is the same name as the DWG and in the same location.

The obvious advantage of this marco is that is that each selected polyline object is treated as a breakline, rather than just points extracted from the polyline. Therefore, the resulting is a surface with similar contours. (The Minimize Flat Areas may still need to be used as a subsequent operation.)

The macro creates an Autodesk Breakline Fault (flt) file (See Civil 3D Help). The following is an example of the format:

S1529.639450 179.318779 100.250000 Polyline1

1188.918348 357.736453 101.420000

1021.998725 330.653391 103.530000

594.008485 610.044279 102.870000

761.574952 744.929530 104.780000

610.233298 754.220180 103.410000

570.572642 923.626865 100.980000

S1542.258750 179.318779 0.000000 Polyline2

1190.721102 350.527660 0.000000

860.816542 446.044194 0.000000

588.600214 619.055276 0.000000

608.430540 743.406990 0.000000

565.164367 925.429066 0.000000

Below is the code in the macro:


Public Sub Breakline_Flt_File()

Dim obj As AcadObject

Dim pt As Variant

Dim fso As New FileSystemObject

Dim ts As TextStream

Dim sPath As String

Dim sFile As String

sPath = ThisDrawing.Path

sFile = ThisDrawing.Name

Set ts = fso.CreateTextFile(sPath + “\” + sFile + “.flt”, True)

Dim nItems As Integer

nItems = ThisDrawing.ActiveSelectionSet.Count

For n = 0 To nItems – 1 Step 1

Dim iSelected As Integer

iSelected = ThisDrawing.ActiveSelectionSet.Count

Set obj = ThisDrawing.ActiveSelectionSet.Item(n)

If TypeOf obj Is AcadLWPolyline Then

Dim pts As Variant

Dim poly As AcadLWPolyline

Set poly = obj

pts = poly.Coordinates

Dim icount As Integer

icount = UBound(pts)

Dim i As Integer

For i = 0 To icount – 1 Step 2

If i = 0 Then

ts.WriteLine “S” & pts(i) & ” ” & pts(i + 1) & ” ” & poly.Elevation & ” ” & “Polyline” & Format(n + 1)


ts.WriteLine ” ” & pts(i) & ” ” & pts(i + 1) & ” ” & poly.Elevation

End If

Next i

End If

Next n

End Sub


As always, use at your own risk and no tech support is offered. Other than that, Enjoy!

Polylinethingy Vertex Extractor and Breakline FLT Writer


  1. JBurke says:

    Great concept for making large data sets easier to handle! One problem: I am having trouble getting the routine to run from the macro dialog box. When run, there is no apparent response. Are there some particular steps we need to follow to run the code? Thanks for all of your efforts to smooth out our C3D trials.

  2. mark minks says:

    i am trying to run the breakline flt writer in C3D 2008 and it willl make the file but it is an empty file. What am i doing wrong?

  3. I don’t believe it’s been updated in sometime. It might not work in 2008, or it might, but you’d have to update references.

  4. It does work in 2008. There is an order to it – I just don’t recall – but I did it last month. It did take me a couple of tries to complete.