3

I have a DXF file that was exported from a drawing of a simple arc that starts at (0, 0), ends at (2, 0) and has a radius of 1.0. I would expect the LWPOLYLINE to be made up of two vertices with the first containing the start point and bulge factor, and the second point simply containing the end point. However, the end point contains a bulge factor as well. How is this bulge point to be interpreted? Shouldn't all vertices with a bulge be followed by another point that defines the end point?

AcDbPolyline
 90
        2
 70
     0
 43
0.0
 10
0.0  -----------------> x1
 20
0.0  -----------------> x2
 42
0.9999999999999998 ---> p1 to p2 w/ bulge = 1, makes sense
 10
2.0  -----------------> x2
 20
0.0  -----------------> y2
 42
1.330537671996453 ----> why does p2 have a bulge? Shouldn't all vertices w/ 
                        a bulge be followed by another point (to define the 
                        end point)?
  0
ENDSEC
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

2 Answers2

6

The best way to find out such details, is to test. If you don't have an AutoCAD application try Autodesk TrueView, it's free.

What I found out by testing is: the last bulge value does nothing, you can change it to any value you want or just delete it, the LWPOLYLINE looks always the same.

EDIT:

This is only true if the LWPOLYLINE isn't closed.

If the LWPOLINE is closed, group code 70=1, the last bulge and also the last start width and end width value, apply to the closing segment from the last vertex to first vertex, your example as closed polyline looks like this:

enter image description here

mozman
  • 2,001
  • 8
  • 23
2

DXF group 70 is bit-coded, with bit 1 indicating that the LWPolyline entity is closed (note that this is not the same as the LWPolyline having coincident endpoints).

With bit 1 set, the bulge factor (DXF group 42) and starting & ending width values (DXF groups 40 & 41) define how the closing segment (i.e. the segment spanning the last vertex & first vertex) should appear.

You can witness the effect of this value in the following examples:

The following entmake expression with the final DXF group 42 entry omitted (and therefore interpreted as 0) produces a polyline as shown in the image:

(entmake
   '(
        (000 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (100 . "AcDbPolyline")
        (090 . 3)
        (070 . 1)
        (010 0.0 0.0)
        (010 1.0 1.0)
        (010 1.0 0.0)
    )
)

Zero Bulge

Whereas the following entmake expression with the final DXF group 42 entry set to -1 (=tan(-pi/4)) produces a polyline as shown in the image:

(entmake
   '(
        (000 . "LWPOLYLINE")
        (100 . "AcDbEntity")
        (100 . "AcDbPolyline")
        (090 . 3)
        (070 . 1)
        (010 0.0 0.0)
        (010 1.0 1.0)
        (010 1.0 0.0)
        (042 . -1.0)
    )
)

Non-zero Bulge

Lee Mac
  • 15,615
  • 6
  • 32
  • 80
  • So, if group 70 = 0, the bulge factor of the final vertex has no meaning? – Darien Shannon Mar 22 '18 at 15:45
  • 1
    @DarienShannon If the polyline is open then, yes, the final bulge factor & starting/ending widths have no meaning. However, since group 70 is a **bit-coded** value, you can't simply test for `0`, but rather test whether bit `1` is set. I'm not sure what language you are using, but in AutoLISP this would be `(zerop (logand 1 (cdr (assoc 70 ))))` – Lee Mac Mar 22 '18 at 17:42
  • Perfect. I am simply parsing the .dxf, in Julia, to convert polylines into an array of points. That being said, the code will just be a string. – Darien Shannon Mar 22 '18 at 22:35