How to write Polygon with DXFLIB ?

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

How to write Polygon with DXFLIB ?

Postby Davidow » Tue May 25, 2010 7:48 am

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?
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Wed May 26, 2010 11:26 am

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>);
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 8:20 am

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>);

Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 8:32 am

To create two separate polylines, please write two separate polyline entities also to the DXF file.
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 10:27 am

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?
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 10:39 am

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.
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 10:53 am

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?
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 10:57 am

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.
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 11:05 am

[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?
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 11:16 am

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.
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 11:23 am

[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.
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 11:25 am

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.
User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Postby Davidow » Thu May 27, 2010 11:43 am

Ou sorry

my English is gruesomely.

I mean entity with Iseland.
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby Davidow » Thu May 27, 2010 11:59 am

How can I implement Hatch?
Davidow
Newbie Member
 
Posts: 9
Joined: Tue May 25, 2010 7:39 am

Postby andrew » Thu May 27, 2010 5:30 pm

User avatar
andrew
Site Admin
 
Posts: 2367
Joined: Fri Mar 30, 2007 6:07 am

Next

Return to dxflib 'How Do I' Questions

Who is online

Users browsing this forum: No registered users and 0 guests