_layers
_layers
¶
High level API for rendering multi layer gerber projects.
LayerParams
¶
Bases: BaseModel
Parameters for Layer object.
source_path
, source_code
and source_buffer
are mutually exclusive.
When more than one of them is provided to constructor,
MutuallyExclusiveViolationError will be raised.
Source code in src/pygerber/gerberx3/api/_layers.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
source_path
class-attribute
instance-attribute
¶
Path to source file containing Gerber code. It will be automatically loaded
from local storage, when provided. Mutually exclusive with source_code
and
source_buffer
.
source_code
class-attribute
instance-attribute
¶
Gerber source code. Mutually exclusive with source_path
and source_buffer
.
source_buffer
class-attribute
instance-attribute
¶
Buffer containing Gerber source code. Buffer pointer should be at the
beginning of the buffer. Mutually exclusive with source_path
and
source_code
.
parser_error
class-attribute
instance-attribute
¶
Callback function or rule describing how to treat errors during parsing.
encoding
class-attribute
instance-attribute
¶
Encoding of code, used when loading from file, decoding source_code
provided as bytes and reading source_buffer
provided as BytesIO.
draw_region_outlines
class-attribute
instance-attribute
¶
When drawing regions, after filling region, draw also outline of region with apertures used for region outlines. This behavior is not expected by KiCAD by default but may be useful in some scenarios.
get_source_code
¶
Return source code of layer.
Layer
¶
Representation of Gerber X3 image layer.
This is only abstract base class, please use one of its subclasses with rendering system guarantees.
Source code in src/pygerber/gerberx3/api/_layers.py
__init__
¶
Create PCB layer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options |
LayerParams
|
Configuration of layer. |
required |
Source code in src/pygerber/gerberx3/api/_layers.py
render
¶
Render layer image.
Source code in src/pygerber/gerberx3/api/_layers.py
get_rendering_result
¶
Return result of rendering Gerber file.
Source code in src/pygerber/gerberx3/api/_layers.py
LayerProperties
¶
Properties of layer retrieved from Gerber source code.
Source code in src/pygerber/gerberx3/api/_layers.py
target_bounding_box
instance-attribute
¶
Bounding box of rendering target. May differ from coordinates used in Gerber file as it uses rendering target coordinate space.
target_coordinate_origin
instance-attribute
¶
Offset of origin of coordinate system used by rendering target. Bottom left corner of coordinate space of rendering target.
gerber_bounding_box
instance-attribute
¶
Bounding box of drawing area in Gerber file coordinate space.
gerber_coordinate_origin
instance-attribute
¶
Origin of coordinate space of Gerber file. Equivalent to bottom left corner of
gerber_bounding_box
.
Can be useful to determine how to align multiple Gerber files by calculating how their coordinate origins are positioned in relation to each other.
__init__
¶
__init__(
target_bounding_box: BoundingBox,
target_coordinate_origin: Vector2D,
gerber_bounding_box: BoundingBox,
gerber_coordinate_origin: Vector2D,
) -> None
Initialize layer properties.
Source code in src/pygerber/gerberx3/api/_layers.py
RenderingResult
¶
Result of rendering of layer.
Source code in src/pygerber/gerberx3/api/_layers.py
__init__
¶
Initialize rendering result object.
save
¶
Save result to specified file or buffer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest |
Path | str | BytesIO
|
Write target. |
required |
**options |
Any
|
Extra parameters which will be passed to saving implementation.
When dest is BytesIO or alike, |
{}
|
Source code in src/pygerber/gerberx3/api/_layers.py
Rasterized2DLayerParams
¶
Bases: LayerParams
Parameters for Layer with 2D rendering.
source_path
, source_code
and source_buffer
are mutually exclusive.
When more than one of them is provided to constructor,
MutuallyExclusiveViolationError will be raised.
Source code in src/pygerber/gerberx3/api/_layers.py
debug_dump_apertures
class-attribute
instance-attribute
¶
Debug option - dump aperture images to files in given directory.
debug_include_extra_padding
class-attribute
instance-attribute
¶
Debug option - include large extra padding on all rendering targets to simplify tracking of mispositioned draw commands.
debug_include_bounding_boxes
class-attribute
instance-attribute
¶
Debug option - include bounding boxes as square outlines on drawing targets to simplify tracking of miscalculated bounding boxes.
Rasterized2DLayer
¶
Bases: Layer
Representation of Gerber X3 rasterized 2D image layer.
Rasterized images can be saved in any image format supported by Pillow library. For full list of supported formats please refer to Pillow documentation.
Source code in src/pygerber/gerberx3/api/_layers.py
__init__
¶
Initialize Layer object.
Source code in src/pygerber/gerberx3/api/_layers.py
Rasterized2DRenderingResult
¶
Bases: RenderingResult
Result of rendering of layer.