_v2
_v2
¶
Module contains implementation details of GerberX3 high level interface of API v2.
OnParserErrorEnum
¶
Bases: Enum
Enumeration of possible actions to take on parser error.
Source code in src/pygerber/gerberx3/api/_v2.py
Ignore
class-attribute
instance-attribute
¶
Ignore parser errors. Errors which occurred will not be signaled. May yield unexpected results for broken files, with missing draw commands or even more significant errors.
Warn
class-attribute
instance-attribute
¶
Warn on parser error. Parser will log warning message about what went wrong. Best for supporting wide range of files without silently ignoring errors in code.
Raise
class-attribute
instance-attribute
¶
Raise exception whenever parser encounters error. Will completely break out of parsing process, making it impossible to render slightly malformed files.
FileTypeEnum
¶
Bases: Enum
Enumeration of possible Gerber file types.
If file type is not listed here you can request adding it by creating an issue on https://github.com/Argmaster/pygerber/issues
Source code in src/pygerber/gerberx3/api/_v2.py
infer_from_attributes
classmethod
¶
Infer file type from file extension.
Source code in src/pygerber/gerberx3/api/_v2.py
GerberFile
dataclass
¶
Generic representation of Gerber file.
This objects provides interface for loading and parsing Gerber files.
Source code in src/pygerber/gerberx3/api/_v2.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
from_file
classmethod
¶
Initialize object with Gerber source code loaded from file on disk.
Source code in src/pygerber/gerberx3/api/_v2.py
from_str
classmethod
¶
Initialize object with Gerber source code from string.
Source code in src/pygerber/gerberx3/api/_v2.py
from_buffer
classmethod
¶
Initialize object with Gerber source code from readable buffer.
Source code in src/pygerber/gerberx3/api/_v2.py
parse
¶
Parse Gerber file.
Source code in src/pygerber/gerberx3/api/_v2.py
ImageFormatEnum
¶
PixelFormatEnum
¶
ParsedFile
dataclass
¶
Wrapper around parsed Gerber file.
This objects allow actions like rendering and retrieving information about file contents.
Source code in src/pygerber/gerberx3/api/_v2.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
get_info
¶
get_file_type
¶
render_svg
¶
render_svg(
destination: BytesIO | Path | str,
*,
color_scheme: ColorScheme = ColorScheme.COPPER,
scale: float = 1.0
) -> None
Render Gerber file to SVG format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
BytesIO | Path | str
|
Destination to save file to. When BytesIO is provided, file will be saved to buffer. When Path or str is provided, they are treated as file path and will be used to open and save file on disk. |
required |
color_scheme |
ColorScheme
|
Color scheme of image, by default ColorScheme.COPPER |
COPPER
|
scale |
float
|
Scale of image, can be used to scale very large or very small images, by default 1.0 |
1.0
|
Source code in src/pygerber/gerberx3/api/_v2.py
render_raster
¶
render_raster(
destination: BytesIO | Path | str,
*,
color_scheme: ColorScheme = ColorScheme.COPPER,
dpmm: int = 20,
image_format: ImageFormatEnum = ImageFormatEnum.AUTO,
pixel_format: PixelFormatEnum = PixelFormatEnum.RGB,
quality: int = 85
) -> None
Render Gerber file to raster image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
BytesIO | Path | str
|
Destination to save file to. When BytesIO is provided, file will be saved to buffer. When Path or str is provided, they are treated as file path and will be used to open and save file on disk. |
required |
color_scheme |
ColorScheme
|
Color scheme of image, by default ColorScheme.COPPER |
COPPER
|
dpmm |
int
|
Resolution of image in dots per millimeter, by default 96 |
20
|
image_format |
ImageFormatEnum
|
Image format to save, by default ImageFormatEnum.AUTO |
AUTO
|
pixel_format |
PixelFormatEnum
|
Pixel format, by default PixelFormatEnum.RGB |
RGB
|
quality |
int
|
Image quality for JPEG format, by default 85. |
85
|
Source code in src/pygerber/gerberx3/api/_v2.py
GerberFileInfo
dataclass
¶
Container for information about Gerber file.
Source code in src/pygerber/gerberx3/api/_v2.py
from_readonly_command_buffer
classmethod
¶
Initialize object with information from command buffer.
Source code in src/pygerber/gerberx3/api/_v2.py
Project
¶
Multi file project representation.
This object can be used to render multiple Gerber files to single image. It automatically performs alignment and merging of files. Files should be ordered bottom up, topmost layer last, like if adding one layer on top of previous.
Source code in src/pygerber/gerberx3/api/_v2.py
parse
¶
Parse all Gerber files one by one.
Source code in src/pygerber/gerberx3/api/_v2.py
ParsedProject
¶
Multi file project representation.
This object can be used to render multiple Gerber files to single image. It automatically performs alignment and merging of files.
Source code in src/pygerber/gerberx3/api/_v2.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
render_raster
¶
render_raster(
destination: BytesIO | Path | str,
*,
color_map: COLOR_MAP_T = DEFAULT_COLOR_MAP,
dpmm: int = 20,
image_format: ImageFormatEnum = ImageFormatEnum.AUTO,
pixel_format: PixelFormatEnum = PixelFormatEnum.RGB
) -> None
Render all Gerber file, align them and merge into single file.
Resulting image will be saved to given destination
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
BytesIO | Path | str
|
Destination to save file to. When BytesIO is provided, file will be saved to buffer. When Path or str is provided, they are treated as file path and will be used to open and save file on disk. |
required |
color_map |
COLOR_MAP_T
|
Mapping from image type to color scheme, by default DEFAULT_COLOR_MAP |
DEFAULT_COLOR_MAP
|
dpmm |
int
|
Resolution of image in dots per millimeter, by default 96 |
20
|
image_format |
ImageFormatEnum
|
Image format to save, by default ImageFormatEnum.AUTO |
AUTO
|
pixel_format |
PixelFormatEnum
|
Pixel format, by default PixelFormatEnum.RGB |
RGB
|
Source code in src/pygerber/gerberx3/api/_v2.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
|