G36 G37 data doubled for polygons


#1

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


#2

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.


#3

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.


#4

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


#5

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)


#6

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.


#7

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.


#8

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


#9

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/


#10

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


#11

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


#12

Thanks Bob, quite rational behaviour…