Using several Viewers, I Opened a Virgin .gbr file and an Edited .gbr file (edited by both my posted code and by Text-Editor) and discovered about half of them opened it as expected with Inverted color.
Thus, success seems to depend on the Viewer. I did Not test Kicad using the few Gerber Options (x2…etc)
FYI-Setting GBR’s to Open with ‘Cuprum’ by Default on my system works perfectly, as shown below… (I Quit and Re-Opened just to be sure of no influence of previous opened file.
From reading info, I learned a good bit about Viewers/Gerbers and observed it’s a mixed bag… I previously mentioned
This seems to be important. Also, Kicad opens Gerber in sequential order of it’s Layer’s in the panel and those layer’s have defined colors. Cuprum/some-others abide by the FilePolarity tag - that is the only difference I see and have read about. Thus, ‘Old’ Vs ‘Modern’, I guess… I’m not an expert, ‘yet’
Can’t say it’s a ‘Bug’, perhaps just older coding…
If you read the Cited above posted Spec, you see Deprecated stuff happened in 2013, example screenshot
You mean file polarity? Probably because its purpose is different. See 5.6.1 in the latest standard, it tells this: “This defines whether the image represents the presence or absence of material.” It doesn’t mean that the image itself is negative graphics. Section 2.3.2 explains object polarity which works for graphics.
You can try a simple trick. A file created by KiCad starts with some lines, then
G04 Created by KiCad (PCBNEW 8.0.4) date 2024-08-02 19:40:10*
%MOMM*%
%LPD*%
If you know the bounding box coordinates of all items together you can create a simple box. I tested by using an unused layer in KiCad and drawing a simple filled rectangle there, covering for example F.Cu layer items. I exported that and copied the exported lines from the gerber:
Then I pasted this before the first %LPD*% line in the F.Cu gerber file and added %LPD*% before the pasted block. I changed the original %LPD*% to %LPC*%. I saved and opened in gerbview, and it worked! The copper layer is seen as negative, having a larger “dark” background box around it, while normally the background is the view canvas.
This is based on the assumption that KiCad doesn’t use “clear” polarity. If the file changes between dark and clear, they all have to be inverted by changing the LP commands, I think.
Here’s the same LPD and LPC converted vice versa, so the background box is drawn as clear on the canvas which makes it invisible, and the result is the original image:
To be honest this thread is perplexing. Fist, I still don’t understand what maui actually wants/needs, what is the end product he wants to achieve.
Second, I think I partly understand why changing the image polarity, IP command, was deprecated. The document says: “As it is not clear how %IPNEG*% must be handled it is probably a waste of time to try to fully implement it, and sufficient to give a warning on a %IPNEG*% and skip it.”
The idea of turning the image to negative is ambiguous. A gerber image is, in the end, an image on a theoretically infinite canvas. Only the coordinate system limits the canvas. To turn the image to negative means either to have a “dark”, “positive” infinite canvas – which doesn’t make sense in documents because infinite can’t be rendered – or to create an arbitrary box where the original image is negative. Even then the “positive” and “negative” are just colors in a document. Normally the image is positive and for example printed with black on the default background, for example white paper. If a negative is wanted, you would need to print the whole paper background or an arbitrary box on it and leave the image unprinted (white paper).
I don’t know if this makes any sense. But because maui understands 3D, I would like to ask: what if someone asked how to create a negative solid in FreeCAD? Does it make sense? Is there an infinite 3D universe where an empty solid can be created? Or is the coordinate system a big solid 3D box inside which you create an empty space?
So, to me turning the image to negative makes sense only if there’s something outside it, apart from the invisible infinite drawing canvas. Therefore I don’t see other option than to create a bounding box inside which the image can be turned negative.
This seems to be what you have found out, too.
But what does “extra manual work” mean? Is running a script extra manual work? I think a script would be pretty easy if the gerber logic goes as I assume – just inverting each LP command. You would then need to decide how to create the background box. But because I don’t know what you actually want, I don’t know how large the box would need to be.
@eelik
mainly I would need to accomplish this task to send to the factory the correct gerber files to be able to visualize in their gerber view the correct final product.
Just to avoid to spend time with their teams and hope the result would be like what I was requesting.
You would then need to decide how to create the background box.
yes, but what I noticed is that the factory previewer is working best with a shape exactly like the edge cuts, but filled…
So my best target would be to manipulate the edge cuts gerber to fill it and then subtract the desired gerber file.
ATM the first part would be manually made.
I would like to be able to obtain the result with a script…
I asked him this probably 3 times already in this thread and am being called obtuse for that.
I still keep an half eye on this thread but do not have much incentive to participate.
From what I can glean from the very little amount of info maui has given, my stance is still that it is probably better to invert whatever objects needs inverting before they get included on the PCB. This circumvents relying on obscure sections of the gerber format, that may or may not be implemented by PCB Fabs.
Nope, I’m not going to waste more time on this. It’s also irrelevant. When you start calling names to people who are trying to help you and ask for more information, then incentive to further help just vaporizes on my side.
I don’t even read more then 3 to 5 lines of new posts.
IMO Paul had a good reason. But let’s leave it at that. Now you gave more information and I understand better what you want.
You can get a filled shape from edge.cuts by drawing a zone on non-copper layer over the board area (reaching outside it) and filling it. The only small drawback is that even when you choose to have no corner shaping, filling does a little bit of filleting, about 0.05 mm radius. I tried and this works as well as a simple rectangle.
Now I again get a feeling that you have obtusely refused to give enough information from the beginning to let us give you better answers. Why didn’t you explain what you actually need, what you have actually done and what better would you need?
@eelik In this chat some people is spending more time in judging then helping, imo.
My first post was explaining exactly what I can do and what I would like to obtain.
Here my first post’s sentence:
Unfortunately it seems it is not possible to invert directly a gerber file…
It seems to me it is necessary to create a filled area covering all pcb area and then subtract to this the file to be inverted.
I would like to know if this feature could be obtained internally in kicad or externally without manual extra work.