From 6a3f52dbaf2b05b85c84c75cf36edc525aa65196 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Mon, 17 Feb 2025 18:27:19 +0000
Subject: [PATCH] Ignore negative layers when exporting Gerbers.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16871
---
 gerbview/export_to_pcbnew.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp
index 0bb9b52a9c..7268395a03 100644
--- a/gerbview/export_to_pcbnew.cpp
+++ b/gerbview/export_to_pcbnew.cpp
@@ -148,6 +148,9 @@ bool GBR_TO_PCB_EXPORTER::ExportPcb( const int* aLayerLookUpTable, int aCopperLa
 
 void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer )
 {
+    if( aGbrItem->GetLayerPolarity() )
+        return;
+
     // used when a D_CODE is not found. default D_CODE to draw a flashed item
     static D_CODE  dummyD_CODE( 0 );