Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gerber-to-svg

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gerber-to-svg

Render Gerber and NC drill files as SVGs in Node and the browser

  • 4.0.0-next.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
593
decreased by-25.69%
Maintainers
1
Weekly downloads
 
Created
Source

gerber to svg

npm

Render Gerber and NC drill files as SVGs in Node and the browser

gerber-to-svg is a library and CLI tool for converting Gerber and NC drill files (manufacturing files for printed circuit boards) into SVG files for the web.

install

npm install --save gerber-to-svg
// or
yarn add gerber-to-svg

example

After you clone and set-up the repository as detailed in development setup, you can run gerber-to-svg's example script to render all the layers of an Arduino Uno PCB.

cd tracespace/packages/gerber-to-svg
yarn run example

Arduino Uno design files used here under the terms of the Creative Commons Attribution Share-Alike license.

usage

var gerberToSvg = require('gerber-to-svg')
var converter = gerberToSvg(input, options, [callback])

See the API documentation for full details.

command line

gerber-to-svg also ships with a command-line utility.

  1. npm install -g gerber-to-svg or yarn global add gerber-to-svg
  2. gerber-to-svg [options] -- gerber_files
options
switchdescriptiontype
-o, --outoutput directorystring
-q, --quietdo not print warnings and messagesboolean
-p, --prettypretty print outputboolean, tab-size
-a, --attrSVG attributes (e.g. --attr.color=blue){[string]: string}
-e, --append-extappend, rather than replace, .svg extensionboolean
-f, --formatcoordinate decimal places format"$int,$dec"
-z, --zerooverride zero suppression"L", "T"
-u, --unitsset backup units to"mm", "in"
-n, --notationset backup absolute/incremental notation"A", "I"
-t, --optimize-pathsoptimize and deduplicate pathsboolean
-b, --plot-as-outlineoptimize paths and fill gapsboolean, max-gap
-v, --versiondisplay version informationboolean
-h, --helpdisplay this help textboolean
examples:
  • gerber-to-svg gerber.gbr - convert gerber.gbr and output to stdout
  • gerber-to-svg -o out gerber.gbr - convert and output to out/gerber.svg
  • gerber-to-svg -o out -a gerber.gbr - output to out/gerber.gbr.svg

background

Since Gerber is a vector image format, this library takes in a Gerber file and spits it out in a different vector format: SVG. This converter uses RS-274X and strives to be true to the latest format specification.

Everywhere that is "dark" or "exposed" in the Gerber (think a copper trace or a line on the silkscreen) will be currentColor in the SVG. You can set this with the color CSS property or the color attribute in the SVG node itself.

Everywhere that is "clear" (anywhere that was never drawn on or was drawn on but cleared later) will be transparent. This is accomplished though judicious use of SVG masks and groups.

The bounding box is carefully calculated as the file is being converted, so the width and height of the resulting SVG should be nearly (if not exactly) the real world size of the Gerber image. The SVG's viewBox is in 1000x Gerber units, so its min-x and min-y values can be used to align SVGs generated from different board layers.

Excellon / NC drill files do not have a completely clearly defined spec, so drill file parsing is lenient in its attempt to generate an image. It should auto-detect when a drill file has been entered. You may need to override parsing settings (see API.md) to get drill files to render properly if they do not adhere to certain assumptions. The library must make these assumptions because Excellon does not define commands for certain formatting decisions.

Keywords

FAQs

Package last updated on 15 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc