Skip to content

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

@Rajkisan

Description

@Rajkisan

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]

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompatibilityRequest for compatibility with some other tool / library versionhelp wantedExtra attention is neededready-for-reproductionIssue is ready for reproduction after all required checkboxes was reported as acknowledged

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions