Page 1 of 2

How to write Polygon with DXFLIB ?

Posted: Tue May 25, 2010 7:48 am
by Davidow
Hello,

Can you help me please.

I'm trying to create polygon with dxflib.

But unfortunately it does not work: (

Maybe you have an outtake from the Sourse code?

Posted: Wed May 26, 2010 11:26 am
by andrew
I assume you mean to write a polyline entity to a DXF file:

Code: Select all

DL_Dxf dxf;

...

dxf.writePolyline(
        <DL_WriterA instance>,
        DL_PolylineData(
                 <number of segments>, 
                 0, 0, 
                 <true for closed polyline, false for open polylines>
        ),
        <DL_Attributes instance>
);

// for every vertex in the polyline:
dxf.writeVertex(
        <DL_WriterA instance>,
        DL_VertexData(
               <vertex position X>, <vertex position Y>, <vertex position Z>, 
               <vertex bulge, always 0.0 for straight segments>
        )
);

dxf.writePolylineEnd(<DL_WriterA instance>);

Posted: Thu May 27, 2010 8:20 am
by Davidow
Thank you!

It works very well. Only now I have another question. How I write a polyline in the polyline entity to a DXF file? I have tried it with Exterior Rings and Internal Rings. But unfortunately when I click on the Exterion area, the Internal polyline was marked to.



andrew wrote:I assume you mean to write a polyline entity to a DXF file:

Code: Select all

DL_Dxf dxf;

...

dxf.writePolyline(
        <DL_WriterA instance>,
        DL_PolylineData(
                 <number of segments>, 
                 0, 0, 
                 <true for closed polyline, false for open polylines>
        ),
        <DL_Attributes instance>
);

// for every vertex in the polyline:
dxf.writeVertex(
        <DL_WriterA instance>,
        DL_VertexData(
               <vertex position X>, <vertex position Y>, <vertex position Z>, 
               <vertex bulge, always 0.0 for straight segments>
        )
);

dxf.writePolylineEnd(<DL_WriterA instance>);

Posted: Thu May 27, 2010 8:32 am
by andrew
To create two separate polylines, please write two separate polyline entities also to the DXF file.

Posted: Thu May 27, 2010 10:27 am
by Davidow
andrew wrote:To create two separate polylines, please write two separate polyline entities also to the DXF file.
Can I write in DXF a close polylines with a hole?

Posted: Thu May 27, 2010 10:39 am
by andrew
A polyline is an entity that consists of a sequence of lines (and sometimes arcs).

Since a polyline is not a shape or surface, it cannot have a "hole" or "island" by definition.

Hatches and solid fills can have holes or islands.

Posted: Thu May 27, 2010 10:53 am
by Davidow
andrew wrote:A polyline is an entity that consists of a sequence of lines (and sometimes arcs).

Since a polyline is not a shape or surface, it cannot have a "hole" or "island" by definition.

Hatches and solid fills can have holes or islands.

I have tried with solid already. That problem is, Solid has only four corners. If i have five corners I can no use it.

Or is it wrong?

Posted: Thu May 27, 2010 10:57 am
by andrew
There are "solid" entities (3-4 corners) and solid hatches (HATCH entity with solid fill, any number of corners, islands, etc.).

If you tell me what you are trying to achieve, I will be able to help much more efficiently, thanks.

Please untick "Disable BBCode in this post" when posting to this forum if you are quoting.

Posted: Thu May 27, 2010 11:05 am
by Davidow
[quote="andrew"]There are "solid" entities (3-4 corners) and solid hatches (HATCH entity with solid fill, any number of corners, islands, etc.).

If you tell me what you are trying to achieve, I will be able to help much more efficiently, thanks.

Please untick "Disable BBCode in this post" when posting to this forum if you are quoting.[/quote]


I want to write a polygon with five corners and in this polygon will be an island.

Can you show me a code example?

Posted: Thu May 27, 2010 11:16 am
by andrew
Does the result have to be one entity (selected as one entity) or two separate entities?
Does the result have to be a filled surface or two outlines only?

Please note: Please untick "Disable BBCode in this post" when posting to this forum if you are quoting.

Posted: Thu May 27, 2010 11:23 am
by Davidow
[quote="andrew"]Does the result have to be one entity (selected as one entity) or two separate entities?
Does the result have to be a filled surface or two outlines only?

Please note: Please untick "Disable BBCode in this post" when posting to this forum if you are quoting.[/quote]


The result have to be a filled surface with two serarate entities.

Posted: Thu May 27, 2010 11:25 am
by andrew
Davidow wrote:The result have to be a filled surface with two serarate entities.
Unfortunately, that is not possible. In DXF, you can store either one entity (a hatch with an island) or two entities (two polygons, no filling).

Please untick "Disable BBCode in this post" when posting to this forum if you are quoting, thank you.

Posted: Thu May 27, 2010 11:43 am
by Davidow
Ou sorry

my English is gruesomely.

I mean entity with Iseland.

Posted: Thu May 27, 2010 11:59 am
by Davidow
How can I implement Hatch?

Posted: Thu May 27, 2010 5:30 pm
by andrew