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

[PyGerber]: When I try to render with .gbr files, getting error pyparsing.exceptions.ParseException #361

Open
6 tasks done
Rajkisan opened this issue Jan 12, 2025 · 5 comments
Assignees
Labels
bug Something isn't working compatibility Request for compatibility with some other tool / library version help wanted Extra attention is needed ready-for-reproduction Issue is ready for reproduction after all required checkboxes was reported as acknowledged

Comments

@Rajkisan
Copy link

PyGerber Bug Report

Mandatory checks

Checks listed below are mandatory for opening a new issue.

If haven't done any of the checks listed below, please do that, we will not look into
the issue until all of the checks in mandatory checks section are checked.

Before opening this issue:

  • I have reviewed the README for guidelines and haven't found a solution there.
  • I have reviewed the PyGerber documentation and haven't found a solution there.
  • I have reviewed the existing open issues and verified that this is not a
    duplicate.
  • I have reviewed the existing closed issues and verified that this was already
    resolved or marked as won't fix.
  • I have reviewed the existing pull requests and verified that this is not a already
    known issue.
  • I have reviewed the existing discussions and verified that this is not a already
    known issue.

This is my code

from pygerber.examples import ExamplesEnum, get_example_path
from pygerber.gerberx3.api.v2 import ColorScheme, GerberFile, PixelFormatEnum

GerberFile.from_file(
    "GerberKicad/dse_vmj_ex_004_legend_top.gbr",
).parse().render_raster(
    "output.png",
    dpmm=100,
    color_scheme=ColorScheme.COPPER_ALPHA,
    pixel_format=PixelFormatEnum.RGBA,
)

It shows

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/rajki/Downloads/Glonix/vm.py", line 6, in <module>
    ).parse().render_raster(
      ^^^^^^^
  File "/Users/rajki/Downloads/Glonix/.venv/lib/python3.12/site-packages/pygerber/gerberx3/api/_v2.py", line 197, in parse
    tokens = Tokenizer().tokenize(self.source_code)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rajki/Downloads/Glonix/.venv/lib/python3.12/site-packages/pygerber/gerberx3/tokenizer/tokenizer.py", line 49, in tokenize
    return self._tokenize_grammar(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rajki/Downloads/Glonix/.venv/lib/python3.12/site-packages/pygerber/gerberx3/tokenizer/tokenizer.py", line 84, in _tokenize_grammar
    ast = grammar.parse_string(source, parse_all=parse_all)[0]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rajki/Downloads/Glonix/.venv/lib/python3.12/site-packages/pyparsing/core.py", line 1216, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected End of file, found '%'  (at char 198), (line:4, col:1)

Expected behavior

It has to render the image of the layer

Environment:

Please complete the following information:

  • Operating system: [macOS24.04]
  • Python version: [3.12.0]
  • PyGerber version: [2.4.2]
@Rajkisan Rajkisan added bug Something isn't working waiting-for-checkboxes Issue is waiting for reporter to check all relevant checkboxes in issue template labels Jan 12, 2025
@Rajkisan
Copy link
Author

Rajkisan commented Jan 12, 2025

Contents of top.gbr file

top.zip

@lily-PHP
Copy link

lily-PHP commented Jan 14, 2025

I got same error message when I parse a GBS file.
here is my code:

from pygerber.gerberx3.api.v2 import FileTypeEnum, GerberFile
parsed_file = GerberFile.from_file(
    "./80600_50_6-ISS1/80600_50_6-ISS1_bott_resist.GBS",
    file_type=FileTypeEnum.INFER_FROM_ATTRIBUTES
).parse()
print(parsed_file.get_info())
print(parsed_file.get_file_type())

here I attach my gerber zip file:
80600_50_6-ISS1.zip

please advise how to solve it.
Thanks,
Lily
80600_50_6-ISS1.zip

@Argmaster
Copy link
Owner

@Rajkisan the problem in with your file is cause by incorrect zero coding mode. D is not an accepted value accoring to Gerber standard. Do you know how this zero coding mode should be interpreted?

%FSDAX44Y44*%

@Rajkisan
Copy link
Author

What Can I do now?

@Argmaster
Copy link
Owner

Argmaster commented Jan 24, 2025

Change declared coordinate format. Try L or T instead of D in FS extended fommand and see if one of them yields reasonable results.

If you determine and share here how to interpret D coordinate coding I can add support for it in PyGerber to mitigate this issue in the future.

@Argmaster Argmaster added help wanted Extra attention is needed compatibility Request for compatibility with some other tool / library version labels Jan 25, 2025
@Argmaster Argmaster moved this to Todo in PyGerber Jan 25, 2025
@Argmaster Argmaster added this to the Distant Future milestone Jan 25, 2025
@Argmaster Argmaster added ready-for-reproduction Issue is ready for reproduction after all required checkboxes was reported as acknowledged and removed waiting-for-checkboxes Issue is waiting for reporter to check all relevant checkboxes in issue template labels Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Request for compatibility with some other tool / library version help wanted Extra attention is needed ready-for-reproduction Issue is ready for reproduction after all required checkboxes was reported as acknowledged
Projects
Status: Todo
Development

No branches or pull requests

3 participants