Argmaster / pygerber

Python implementation of Gerber X3/X2 standard with 2D rendering engine.
https://argmaster.github.io/pygerber/stable
MIT License
54 stars 10 forks source link

[PyGerber]: When I am trying to import and render .art Gerber Files from Cadence Allegro, it shows error #333

Open Rajkisan opened 2 weeks ago

Rajkisan commented 2 weeks ago

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:

This is my code

from pygerber.gerber.api import GerberFile

# Function to read the file content and process it with pygerber
def process_gerber_file(file_path):
        # Open the Gerber file and read the entire content into a string
        with open(file_path, 'r') as gerber_file:
            gerber_content = gerber_file.read()

        # Create a GerberFile object using pygerber and load the content as a string
        outline_layer = GerberFile.from_str(gerber_content)
        vm = outline_layer.render_with_pillow()
        bounding_box = vm.get_image_space()
        width = bounding_box.max_x_mm - bounding_box.min_x_mm
        height = bounding_box.max_y_mm - bounding_box.min_y_mm
        print(width, height)

# Example usage: Replace with the path to your Gerber file
gerber_file_path = "BOTTOM.art"
process_gerber_file(gerber_file_path)

It shows raise EmptyAutoSizedLayerNotAllowedError(top_layer.layer_id) pygerber.vm.types.errors.EmptyAutoSizedLayerNotAllowedError: id='%main%'

Expected behavior

It has to return the size by width and height of the layer

Environment:

Please complete the following information:

Rajkisan commented 2 weeks ago

Flexray_board_fabrication_and_assembly.zip TOP.art and BOTTOM.art

Argmaster commented 2 weeks ago

Hi, thanks for reporting the issue. If I were to quickly point some fingers on possible culprits, this behavior can be triggered by for example rendering empty file or rendering with too low resolution. I haven't yet investigated deeper, I will do that soon. I acknowledge that this is not the most helpful message one could get, I will work on that in the future releases. Issue #313 is somewhat related, but I haven't yet started working on that.