Coder Social home page Coder Social logo

inkscape-openscad-poly's Issues

Limiting significant digits

Per Schmarty, "I pushed an update a couple of days ago to have it keep 5 significant digits. Due to how floats are stored, this can sometimes produce weird long numbers due to small float errors."

For most printing purposes 1 significant digit, and at a maximum 2, would be more than adequate. This would mean precision down to 0.01mm, which is about as fine a feature as anyone would need from an Inkscape->OpenSCAD polygon tool. The current setup (as of 2011/10/23) is creating very long significant digit pairs for XY coordinates. Example, "[-11.556710000000001, -0.96667000000000003]". For my purposes, "[-11.6,-1.0]" would be sufficient.

Deprecation Warnings with Inkscape 1.1.1 (3bf5ae0d25, 2021-09-20)

The plugin works just fine, but these are thrown up.

C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad-poly.py:31: DeprecationWarning: Effect.OptionParser or `optparse` has been deprecated and replaced with `argparser`. You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.
  self.OptionParser.add_option("--tab",
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad-poly.py:47: DeprecationWarning: Effect.affect is now `Effect.run()`. The `output` argument has changed.
  e.affect()
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad-poly.py:39: DeprecationWarning: self.svg_file is now self.options.input_file.
  self.context = OSCADPolyContext(self.svg_file)
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:355: DeprecationWarning: simpletransform.parseTransform -> Transform(str).matrix
  mat_new = composeTransform(mat_current, parseTransform(node.get("transform")))
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:355: DeprecationWarning: simpletransform.composeTransform -> Transform(M1) * Transform(M2)
  mat_new = composeTransform(mat_current, parseTransform(node.get("transform")))
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:92: DeprecationWarning: simplepath.parsePath -> element.path.to_arrays()
  if len(simplepath.parsePath(d)) == 0:
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:94: DeprecationWarning: cubicsuperpath.parsePath -> None
  p = cubicsuperpath.parsePath(d)
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:95: DeprecationWarning: simpletransform.applyTransformToPath -> Path(path).transform(mat)
  applyTransformToPath(mat, p)
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:61: DeprecationWarning: inkex.bezier.maxdist -> Get maximum distance within bezier curve
  if cspsubdiv.maxdist( b ) > flat:
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad_poly\svg_parser.py:67: DeprecationWarning: inkex.bezier.beziersplitatt -> Split bezier at given time
  one, two = beziersplitatt( b, 0.5 )
C:\Users\spamt\AppData\Roaming\inkscape\extensions\openscad-poly.py:47: DeprecationWarning: Use `save()` or `save_raw()` instead.
  e.affect()

NameError: global name 'new_path_from_node' is not defined

I opened an SVG file and tried to export it to OpenSCAD using File -> Save a copy. It crashed with the following message:

Traceback (most recent call last):
  File "openscad-poly.py", line 45, in <module>
    e.affect()
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "openscad-poly.py", line 39, in effect
    parser.parse()
  File "/Users/bzamecnik/.config/inkscape/extensions/openscad_poly/svg_parser.py", line 231, in parse
    self.recursivelyTraverseSvg(self.svg, [[0.28222, 0.0, -(self.svgWidth/2.0)], [0.0, -0.28222, (self.svgHeight/2.0)]])
  File "/Users/bzamecnik/.config/inkscape/extensions/openscad_poly/svg_parser.py", line 288, in recursivelyTraverseSvg
    entity = self.make_entity(node, matNew)
  File "/Users/bzamecnik/.config/inkscape/extensions/openscad_poly/svg_parser.py", line 302, in make_entity
    entity.load(node,mat)
  File "/Users/bzamecnik/.config/inkscape/extensions/openscad_poly/svg_parser.py", line 135, in load
    newpath = new_path_from_node(node)
NameError: global name 'new_path_from_node' is not defined

This is the SVG:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="5096.659px" height="1203.185px" viewBox="0 0 5096.659 1203.185" enable-background="new 0 0 5096.659 1203.185"
     xml:space="preserve">
<path d="M3292.065,752.765l-61.176-173.236c-6.399,90.18-23.767,160.539-52.24,213.287L3292.065,752.765z"/>
<path d="M2539.363,171.933l-275.14,97.162c114.564,13.474,193.766,90.249,193.766,221.161v47.074
    c0,88.113-27.763,149.672-101.39,176.226c76.042,24.141,101.39,94.147,101.39,185.882v35.003c0,48.227-9.746,89.341-28.094,122.789
    l388.361-137.144h-278.892V171.933z"/>
<path d="M3006.162,494.167c0-213.828-32.84-240.999-87.965-240.999h-151.298v473.173h151.298
    C2985.05,726.341,3006.162,660.74,3006.162,494.167z"/>
<path d="M2223.826,892.195v-10.863c0-55.524-33.796-57.937-111.046-61.559l-196.745-8.448v-190.71l196.745-12.07
    c83.285-3.622,113.46-3.622,113.46-59.145v-10.863c0-61.559-50.696-61.559-113.46-61.559h-278.822v-55.941l-83.205,29.383
    l176.467,499.712h178.318C2199.685,950.132,2223.826,948.926,2223.826,892.195z"/>
<polygon points="2016.582,1203.185 2135.017,1161.361 2001.813,1161.361 "/>
<path d="M3053.834,78.151L3026.236,0l-168.273,59.423h83.692C2984.77,59.423,3021.914,65.961,3053.834,78.151z"/>
</svg>

Other units than px, % or none (such as mm) should be handled

Same SVG as in #3.

Traceback (most recent call last):
  File "openscad-poly.py", line 45, in <module>
    e.affect()
  File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "openscad-poly.py", line 39, in effect
    parser.parse()
  File "/Users/bzamecnik/.config/inkscape/extensions/openscad_poly/svg_parser.py", line 229, in parse
    self.svgWidth = self.getLength('width', 354) * 0.28222
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

Changes for Inkscape 1.0?

Got an email about possible updates to make:

Thank you for providing this extension for Inkscape users!

This is just to let you know that most 3rd party Inkscape extensions,
like the one you made, probably will not work with the upcoming new
Inkscape version, the long-awaited version 1.0.

Here is the info you need to update this extension, so that it will work
with 1.0 and future versions.
https://wiki.inkscape.org/wiki/index.php?title=Updating_your_Extension_for_1.0

If you have further questions, you can contact Inkscape developers via
mailing lists (https://lists.inkscape.org/postorius/lists/?all-lists),
forum (https://inkscape.org/forums/extensions/), or the chatroom
(https://chat.inkscape.org/channel/team_devel)

If you have already updated it, please disregard this message.

Extension does not show up in Inkscape 1.2 for Windows

Running Inkscape 1.2.2 on Windows 10.

Copied the contents of the /src folder to C:\Program Files\Inkscape\share\extensions
Opened a .png file, Shift-Alt-B to "Trace Bitmap". Preview contains what I want. Apply.
Select the object, then go to "Path" menu and choose "Object To Path".
Go to "File" and select "Save a Copy". There is no file type for "OpenSCAD polygons" in the filetype menu. (see attached screenshot),

Got the same results after copying the contents of the /src folder to C:\Users[MyUserName]\AppData\Roaming\inkscape\extensions

InkscapeSaveCopy

Parameters

First off, I really appreciate all of the work that you have put into this. If you could do a little more, it would be greatly appreciated. I see that the output has smoothness hardcoded and the relevant(?) line says subdivide_cubic_path(sp, 0.2) # TODO: smoothness preference. Can you please add that (and anything else helpful) to the interface?

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.