gerbview: RS274x import, Aperture Macro, overwriting of variables
Description
Loading the following Aperture Macro, the size of the generated Octagon is incorrect:
%AMVB_LOCTAGON*
$4=$2/4.8284*
$1=$1/2*
$2=$2/2*
$5=$2-$4*
4,1,8,$1-$5,$2,$1,$4,$1,0-$4,$1-$5,0-$2,$5-$1,0-$2,0-$1,0-$4,0-$1,$4,$5-$1,$2,$1-$5,$2,$3*
%
This seems to be because rather than overwriting parameter $2 in m_localparamStack (see rs274x.cpp:1007ff), a new parameter in the stack is generated with the same Index, but given that the search order is always forward, that parameter is never used. The given macro is easy to fix in the gerber file so as to be processed correctly by gerbview, but I find it hard to estimate how to fix the code, so that overwriting of parameters is possible. Whilst I am not sure whether RS274X explicitly allows or forbids this behaviour, I think the definition of two parameters with the same index, should at least throw a message, as one of them will not be used at all.
Steps to reproduce
- I attach two files (faulty, using variable overwrite, and working, using a new variable), these should produce the same output, but faulty obviously lacks a factor of 2 in downsizing.
KiCad Version
Application: GerbView
Version: (5.1.9)-1, release build
Libraries:
wxWidgets 3.0.5
libcurl/7.71.0 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.41.0
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.73.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.71.0
Compiler: GCC 10.2.0 with C++ ABI 1014
Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON
Edited by Jens Dopke