Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces around equals in gerber pad shape variable definition formula #354

Open
adneedle opened this issue Dec 15, 2020 · 2 comments
Open

Comments

@adneedle
Copy link

When Mentor Xpedition creates shape definitions in gerber files, it seems to add spaces around equal signs in the variable definition formulas. For example:

%AMVB_Custom_Oblong*
21,1,$2-$3,$3,0,0,$1*
$2 = $2/2*
$3 = $3/2*
$6 = $2-$3*
1,1,$3X2,$4X$6,$5X$6*
$6 = 0-$6*
1,1,$3X2,$4X$6,$5X$6*
%

This causes the regular expression in _parse-macro-block.js, var RE_VAR_DEF = /^(\$[\d+])=(.+)/, to fail to match. The pad variable definitions are then out of sync for the file and it tries to use undefined variables.

I am not sure if the spaces around the equal signs comply with the gerber spec, but I ended up locally changing the regex to var RE_VAR_DEF = /^(\$[\d+])\s?=\s?(.+)/ to make it work in my situation.

@mcous
Copy link
Member

mcous commented Dec 15, 2020

Very interesting. This is 100% not compliant with the Gerber File Format specification

3.3 Character Set
...
Space characters can only be used inside strings (see 3.6.5).

If possible, I would definitely raise a bug report with Mentor for this.

From a tracespace perspective, yeah I think allowing the equal sign regex to have some optional spaces makes sense for leniency, if that leniency is common in other Gerber viewing tools. The risk in leniency is that it may give someone a false sense of security that their invalid Gerber file will be understood by a fab. I would also probably limit the regex to just literal space characters rather than \s, but I'd accept a PR for this functionality.

@adneedle
Copy link
Author

Thanks. It does not surprise me very much that the Xpedition gerber output is buggy. I am not sure if we have seen a fab issue before, but that may be because we almost always use ODB++ now for the fab data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants