OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

SVG import should work for a logo example

Open WolfgangFahl opened this issue 6 years ago • 5 comments

Expected Behavior

SVG import should work

Actual Behavior

//
  // producer: OpenJSCAD.org 1.9.0 SVG Importer
  // date: Mon Aug 26 2019 11:14:38 GMT+0200 (Mitteleuropäische Sommerzeit)
  // source: BITPlanLogo2012FontLess.svg
  //
  function main(params) {
  var cag0 = new CAG();
    var cag1 = new CAG();
      var cag2 = new CAG();
        var cag3 = new CAG();
          var cag4 = new CAG();
        var cag30 = cag4;
        cag3 = cag3.union(cag30);
      var cag20 = cag3;
      cag20 = cag20.translate([5.644443999999999,-5.644443999999999]);
      cag2 = cag2.union(cag20);
    var cag10 = cag2;
    cag1 = cag1.union(cag10);
      var cag2 = new CAG();
        var cag3 = new CAG();
          var cag4 = new CAG();
        var cag30 = cag4;
        cag30 = cag30.translate([0,0]);
        cag3 = cag3.union(cag30);
      var cag20 = cag3;
      cag2 = cag2.union(cag20);
    var cag11 = cag2;
    cag11 = cag11.translate([342.05330639999994,-279.399978]);
    cag1 = cag1.union(cag11);
  var cag00 = cag1;
  cag00 = cag00.scale([0.29333,0.29333]);
  cag00 = cag00.translate([-47.977774,-10.1599992]);
  cag0 = cag0.union(cag00);
  return cag0;
}

does not show as grafik

Steps to Reproduce the Problem

  1. Drag and Drop http://wiki.bitplan.com/images/wiki/7/7a/BITPlanLogo2012FontLess.svg or try https://openjscad.org/#http://wiki.bitplan.com/images/wiki/7/7a/BITPlanLogo2012FontLess.svg

Specifications

  • Version: 1.10.0
  • Platform: MacOS 10.3.6
  • Environment: Firefox 65

WolfgangFahl avatar Aug 26 '19 10:08 WolfgangFahl

To maximize compatibility, you could deep ungroup, unlink clones, add points (enough to keep your curves) and turn it to lines, then it should import correctly.

gilboonet avatar Aug 27 '19 09:08 gilboonet

@gilboonet - this is already the "fontless" version using no external references as the original would do. Further "simplifying" it would certainly be possible. And indeed i was already able to create an STL of the logo using other tools. I'd rather see the importer being improved and that's what my issue is about.

WolfgangFahl avatar Aug 27 '19 10:08 WolfgangFahl

@WolfgangFahl thanks. I’m looking at this now for V2. I’ll report back if a fix is possible for V1.

z3dev avatar Aug 27 '19 10:08 z3dev

@WolfgangFahl congradulations. you found a bug.

sadly, it's not an easy bug to fix because the support for 'defs' was intermixed with the support for 'groups'. the solution was to handle the 'defs' specifically.

the example SVG file includes this.

  <def>
    ...
    <g id='heureka0'>
      <g transform='translate(1335.6224155638808,423.01254844961903) rotate(29.5)'>
        <use xlink:href='#kopf0' />
      </g>
      <g transform='translate(0,0)'>
        <use xlink:href='#heurekabody' />
      </g>
    </g>
    ...
  </def>

the nesting of 'defs' causes the issues. you can fix this by replacing the 'use' with the SVG entity.

z3dev avatar Aug 30 '19 08:08 z3dev

V2 fixes most of the issues, except #523. I have never seen ‘mirror’ before in SVG files so I’m not sure when this will be totally supported.

@WolfgangFahl a simple question... what application produced the SVG?

z3dev avatar Feb 23 '20 09:02 z3dev