G36 G37 data doubled for polygons

I’m writing a simple tool to have my pcb plotted as vectors.

Why the data of polygons (fills) is repeated after G36 almost identical also after G37?

What is the idea and what are the differences exactly. With a quick look I see the only difference being that in G36 the last vector is listed two times?

Here’s a simple triangle example:

G36*
X48969771Y-29219076D02*
X43668363Y-23435721D01*
X51620476Y-21266963D01*
X48969771Y-29219076D01*
X48969771Y-29219076D01*
G37*
X48969771Y-29219076D02*
X43668363Y-23435721D01*
X51620476Y-21266963D01*
X48969771Y-29219076D01*

Tom

G35/G36 defines filled regions. The duplication of the last point is probably just to make sure the contour is closed.

The second set (after G37) effectively draws the outline of the filled area, I’m not sure what the purpose of that is.

The comment in the code says this :

// Gerber format does not know filled polygons with thick outline
// Therefore, to plot a filled polygon with outline having a thickness,
// one should plot outline as thick segments

G36/G37 draw the region with a zero thickness line, so the outline is traced over again with the desired line thickness.

1 Like

G36 enables region mode
G37 disables region mode

Both are only in the extended Gerber format
see https://www.ucamco.com/files/downloads/file/81/the_gerber_file_format_specification.pdf
As for their correct use I don’t know.

1 Like

I forgot to ask, what does that mean exactly? Is it for milling?

Do you start form gerber or do you have a kicad project to start with?

If you start from kicad you could try out the svg plot option. Maybe this already does what you want to achieve.
(Could also be useful for testing your tool)

Bobc,

The output at this stage is G-code for 3d-printer to control a laser exposuring the UV mask, and maybe doing the drilling as well.

Rene,

I’m using Kicad to design. I’m aware there are some tools doing plotting with bitmaps, but my (maybe too) ambitious idea is not going back and forth with vectors and bitmaps (G-code is vectors).

I’m also aware of not achieving the “negative” parts this way but this is for my own projects - and whenever the gerber gets too complicated, I might then add some pixel based parts.

Although, I’m using only one size of focus at this stage.

At least you don’t have to find a Fab that reliably supports Extended Gerber, something that would be hard where I am at this time

David,

Yes, this is for prototype projects when I don’t want to wait two weeks the boards from China just to see I made some errors… :slight_smile:

But, so far, so good - the pads and holes are behaving nice, and like said, writing few lines to do the fillings now.

BTW : If anyone wants to test the G-code, this has worked nice for me: https://nraynaud.github.io/webgcode/

1 Like

Does anyone one if Kicad is drawing the polygon always CCW, or does this vary?

I think it is in the same order that the user drew the filled area, so could be CW or CCW.

Thanks Bob, quite rational behaviour…