Skip to content

martymcguire/inkscape-openscad-poly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OpenSCAD Polygon Output for Inkscape

This is an Inkscape extension that allows you to save your Inkscape drawings as OpenSCAD (.scad) files containing modules with 2D polygons suitable for extruding into 3D shapes.

Website: http://github.com/martymcguire/inkscape-openscad-poly

Contributors

Credits

Install

Copy the contents of src/ to your Inkscape extensions/ folder.

To find this folder you will need to check the instructions for your specific operating system and Inkscape installation type.

An incomplete list of possible locations by platform:

  • OS X - /Applications/Inkscape.app/Contents/Resources/extensions
  • Linux - /usr/share/inkscape/extensions
  • Windows - C:\Program Files\Inkscape\share\extensions

Usage

  • Size and locate your image appropriately:
    • Setting units to mm in Inkscape makes it easy to size your drawing.
    • The extension will automatically attempt to center everything.
  • Convert all text to paths:
    • Select all text objects.
    • Choose Path | Object to Path.
  • Save as OpenSCAD:
    • File | Save a Copy.
    • Select OpenSCAD Polygons (*.scad).
    • Save your file.

Use in OpenSCAD

You'll find each path from your Inkscape file appears as a module in the resulting OpenSCAD file.

The resulting OpenSCAD also contains a list of every generated module at the beginning. This allows easy control of the generated polygons by simply previewing in OpenSCAD (with F5 key) and can be easily disabled by commenting out or deleting the lines. If the paths in the SVG file use simple basic colors (no color gradient) this color is also transformed into an OpenSCAD color() statement and added before the module. Be aware that unfortunately OpenSCAD uses color only in preview mode (F5) not in render mode (F6).

For example:

// my_drawing.scad
module badge_face() {
  polygon(points=
	[[-16.704628355490897, -20.69348168358303], [-13.479257330090903, -35.207652708983034], [-2.1904573300909078, -23.918852708983053], [17.161771644509102, -71.493081683583029], [-11.866570406290904, -40.045710658183026], [-13.479257330090903, -63.429652708983014], [-36.056857330090907, -56.172565785182996], [-30.412457330090902, -2.9539396327830048], [-0.57777040629089527, -1.3412527089830064], [16.355429593709104, -20.693481683583002], [38.126687542909096, -57.785252708983023]]
	, paths=
	[[0, 1, 2, 0], [3, 4, 5, 6, 7, 8, 9, 10, 3]]
	);}

You can include this file in your OpenSCAD program and use OpenSCAD's 2D-to-3D extrusion methods, calling these modules to get the 2D data!

// my_object.scad
include <a_badge.scad>;

linear_extrude(height=20)
  badge_face();

TODOs

  • Use square and circle where applicable for simplicity?
  • Combine layer contents into single modules?
  • Parameterize smoothness for curve approximation (dirty workaround: Scale up in inkscape and down in OpenSCAD).
  • Include example files/templates.

Special attribution notes

About

Inkscape extension for exporting drawings as OpenSCAD modules of polygon() calls.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages