Giter Site home page Giter Site logo

sketchup_svg_importer's Introduction

Sketch SVG Importer

This is a plugin for Sketchup versions 6+. Use it to import simple SVG images into sketchup, where they can be extruded into 3D and further modified.

This version extends the excellent script by Uli Tessel with some additional features and bug fixes.

Dependencies

  • The Bezier.rb plugin, available from the Ruby Library Depot
  • The rexml ruby library
  • forwardable.rb
  • set.rb

Forwardable and set shipped with a standard ruby installation. REXML should come with 1.8, but sketchup seems to expect it to be located inside the plugins folder. Just copy the directory to your plugins directory.

Installation

Copy svg.rb to your plugins folder. On Windows, this will be C:\Program Files\Google\Google SketchUp #\Plugins. On a Mac, ~/Library/Application Support/Google SketchUp #/SketchUp/plugins. Bezier.rb can be installed the same way.

Installing the other three dependencies can be troublesome. Some instructions for getting them on Windows are given in this thread.

On a Mac using MacPorts, forwarded.rb and set.rb were loaded automatically (since Macs ship with Ruby). I used the following commands to install rexml.

sudo port install rb-rexml
ln -s /opt/local/lib/ruby/vendor_ruby/1.8/rexml "~/Library/Application Support/Google SketchUp 8/SketchUp/plugins"

Usage

The plugin adds a 'Import SVG File...' option in the Plugins menu. The SVG will be imported into a new group. The object structure within the SVG will be preserved, meaning that groups of objects within the SVG will become nested groups in Sketchup. Note that several explode operations may be required to move geometry into the top-level model.

Global Flags

The following flags can be set using the ruby console to help with debugging and change some behaviours:

  • _$svgImportScriptDebug _If true, print debugging information

Limitations

The plugin can currently handle only a limited subset of the SVG format. Unsupported features typically print a warning to the ruby console and then are ignored.

When using Inkscape, the following hints can produce simpler, more compatible svg output

  • Convert all objects to paths before exporting (text, polygons, etc)
  • Save files as 'Plain SVG' ('Simple SVG' in some locales)

(Suggested by Sketchucation user TIG)

Known Conflicts

The SVG Importer uses set.rb, which conflicts with Sketchup's built-in Set class. This causes problems with some programs which require Set, namely smoove from Sandbox Tools.

Known Bugs/Missing features

These are not implemented, but have been started or planned. Additional feature requests can be made on github

  • Additional SVG Types
    • line, polyline, polygon, text
    • Additional path commands (arc, quadratic bezier, etc)
  • Localization
    • The 'french' branch contains french translations of some messages. If some french speaker would be interested in updating this branch with the latest features it would be great.
  • 3D-specific attributes
    • It might be interesting to use some attributes (like the color of a stroke) to control the Z-Value. With this common trick it is possible to use Inkscape for some kind of 2.5D.
  • Bug: faces are not created correctly: too many, holes are wrong, etc.
  • Bug: Incompatible with smoove

License

Code is released under GPL 3. See LICENSE for the full terms.

History

0.5 Support for Sketchup 2014

  • Ruby 2.0 compatibility
  • Minor bug fixes

0.4 SVG compatibility improvements (Spencer Bliven)

  • Support for relative coordinates in paths
  • Removed need for repeat commands

0-0.3 Copyright (C) 2008 Uli Tessel ([email protected])

sketchup_svg_importer's People

Contributors

sbliven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sketchup_svg_importer's Issues

Plugin broken in Sketchup 2014

In recent sketchup versions, the plugin gives exceptions on the console. The first of these is:

Error: #<TypeError: no implicit conversion of NoMethodError into String>
/Users/blivens/Library/Application Support/SketchUp 2014/SketchUp/Plugins/svg.rb:878:in `+'
/Users/blivens/Library/Application Support/SketchUp 2014/SketchUp/Plugins/svg.rb:878:in `rescue in ParseFile'
/Users/blivens/Library/Application Support/SketchUp 2014/SketchUp/Plugins/svg.rb:859:in `ParseFile'
/Users/blivens/Library/Application Support/SketchUp 2014/SketchUp/Plugins/svg.rb:902:in `DoSVGImport'
/Users/blivens/Library/Application Support/SketchUp 2014/SketchUp/Plugins/svg.rb:910:in `block in <top (required)>'
-e:1:in `call'

Michael reports a different error:

Error (in script) while reading "C:\bla\bla\file.svg":
undefined method `encoding' for "<?x":String

Won't import paths, strokes, clones and so on...

I've tested the plugin and the imported shapes are crippled.
It imports shapes (like rectangle), but fails to import paths, text, strokes, etc.
If the file is saved as Plain SVG, some paths are imported, but incorrect (missing nodes).

It would be a very good plugin, if it would work properly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.