cart: empty [ Login ]

DONUT Polyline?

1 
foolfu
4/30/2008 8:49 PM
Hi, I am importing a DXF file to my application. How can I import and export a Donut polyline from DXF file to my application? So far, I can import and export the regular polyline, but I have problem with the Donut polyline. And the structure of my source code is like this: private string LwpolylineToXml( DxfLwPolyline p) {   .......   foreach (DxfLwPolyline.Vertex v in p.Vertices)   {      .....   }   ....... } Thanks. D
Wout
4/30/2008 9:15 PM
Hi, Do you have a sample file that I can have a look at? Thanks! Wout
foolfu
4/30/2008 9:56 PM
I just upload it to the link here: http://download.yousendit.com/26CA68C55CCE445E You can see there are two dots (Donut polylines) in this file. They are Donuts with Global width 2'. Also, you can just type 'donut' in AutoCad command line, then you will be able to create a donut polyline as well. Thanks.
Wout
5/2/2008 1:25 PM
Hi, I've taken a closer look, it seems like the LWPOLYLINE entities have the by layer line type of the Grid layer (default). This turns out to be the CENTER line type, which has dashing. That's why you see the odd pattern. If you switch to the normal CONTINUOUS line type, you'll see a proper dot. Let me know if this works out ok! Wout
foolfu
5/2/2008 8:43 PM
Hi, Thanks for answering my question. But actually, my question was 'how to detect or find out the Lwpolyline is a Donut?'. For example, if I want to find out if a Lwpolyline is a polygon, I can check its property: IF DxfLwPolyline.Closed IS TRUE THEN POLYGON. Is there any way or solution to check if a Lwpolyine is a Donut? Thanks again,
Wout
5/2/2008 8:56 PM
Ah, I misunderstood. The two vertices of the polyline have a bulge of 1, so the donut just consists of two semi circles (arcs). See properties DxfLwPolyline.Vertex.Bulge, or DxfVertex2D.Bulge if using DxfPolyline2D. Wout
foolfu
5/2/2008 9:08 PM
The two vertices have a bulge of 1, with polyline.Close property is TRUE, then it creates a Donut shape. But if the polyline.Close property is FALSE, then it creates a Half Donut shape (semi-circle). How do I know the Half Donut shape (semi-circle arc) is from either start vertex (0 degree) to end vertex (180 degree), or end vertex (180 degree) to start vertex (0 degree)? Thanks alot!
Wout
5/2/2008 9:12 PM
You already said it: if there's 2 vertices with bulge 1 (-> semi circle), and the polyline is closed, then the second arc is just as long as the first arc, because the distance from point 1 to point 2 is the same as the distance from point 2 to point 1 (the closing segment). The polyline itself doesn't really know it's a donut, it just knows it has straight line and arc segments. But with some special care you can deduce it's a special donut polyline. Wout
foolfu
5/2/2008 9:46 PM
ha, sorry.. I didn't explain the question well. Actually, I was going to ask if the donut arc draws in counter-clockwise way or clockwise way from point 1 to point 2. But after reading your last reply, I think it should go by counter-clockwise. Thank you so much for the help! I really appreciate it. :D
Wout
5/2/2008 9:51 PM
You're welcome! Here's an excerpt from the CadLib documentation on the DxfVertex2D.Bulge property:
The bulge is the tangent of one fourth the included angle for an arc segment, made negative if the arc goes clockwise from the start point to the endpoint. A bulge of 0 indicates a straight segment, and a bulge of 1 is a semicircle.
So bulge would be either -1 or 1, but typically 1, not much sense in reversing it in this case. Wout
1