I’m using POLYLINE for my dxf export all is good except I can’t smoothen the arc’s it always returns as straight edges(lines). Then I stumbled upon LWPOLYLINE. The arcs are smooth but I don’t know how do I correctly generate an arc. I ran into 2 major issues
I separated the Curve line but the figure is still closing (notice the straight line)
I don’t know where I could get the value I could use for the bulge and where do I put it
In the example,what I did is I extract the first and last vertex of the arc then add the bulge on the last vertex (used the end_angle). The white one is the one that I generated
Basically Im writing a dxf exporter and I can’t get the arc part done so I’m trying to seek an advice on how to draw an arc from an Sketchup::Edge or Sketchup::ArcCurve object. Right now I’m using a LWPOLYLINE command on the dxf part. It is written like this:
According to the DXF spec, the bulge is not code 43 (which is constant width.)
I’d think you’d need to use a combination of 41 and 42. (See pp 102…103)
DXF spec, page 251, establishes that the LWPOLYLINE is a 2D entity, and it’s vertices are 2D, expressed within the OCS (the entity’s local coordinate system.) So you’ll need to know how to determine the world coordinates of the SketchUp entity and transform that into the DXF entity’s OCS. (pp 251…252)
If the SketchUp curve is not within a group or component instance, then the coordinates of the points will be in model coordinates. If they are grouped or in a component, then you’ll need to multiply the instance transformations of the nestings, to convert to “world” coordinates.
Thanks for the info I manage to generate a near replicate of the shape that I want. Using the ArcCurve I filtered out the vertices and just add a bulge on the vertex before the arc now it looks like this
Do you think is there a way that I could set or even derive the bulge value (42) from the ArcCurve object?
Thanks here’s a snippet of the code using the formula but I think I missed something.
vertices = curve.vertices.values_at(0, -1)
r = curve.radius
l = vertices.first.position.distance(vertices.last.position).to_f / 2
s = r - (Math.sqrt((r**2) - (l**2 )))
Hmm…I tried your code on a sample I drew using the SketchUp arc tool, and it returned the correct value. Can you share the model for which you got an incorrect value? I know nothing about LWPOLYLINE, but I can try to help with SketchUp
I think the question you are asking is addressed on this page:
The curvature of a Polyline Arc segment is defined using a quantity known as bulge. This unit measures the deviation of the curve from the straight line (chord) joining the two vertices of the segment. It is defined as the ratio of the arc sagitta (versine) to half the length of the chord between the two vertices; this ratio is equal to the tangent of a quarter of the included arc angle between the two polyline vertices.
In this way, a negative bulge indicates that the arc follows a clockwise direction from the first vertex to the next, with a positive bulge describing an anticlockwise oriented arc. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.
An AutoCAD Arc Entity is defined by a center, radius and start & end angle. The arc is always defined to be anticlockwise oriented, that is, following an anticlockwise direction from the start angle to the end angle.