4
$\begingroup$

In OpenSCAD, I am trying to make a linear_extrude on a shape imported from an svg. The svg file contains multiple path. I would like to scale each path separately. I have tried the following code, but the whole import is considered a single shape resulting in the image below.

linear_extrude(height = 5, center = true, scale=1.2)
    import(file = "xxx.svg", center = true, dpi = 96);

result

How can I have each of the letters to have 'its own pyramid' ?

I know I could create one SVG per letter. But for simplicity sake I would like to have only one SVG file, as I want to create much more complex motives in the future. My final goal is to create stamps from SVG drawings.

Edit: Alternative tried after Mick's comment (same result):

module pyramidChildren(height){
    for ( i= [0:1:$children-1])  
      linear_extrude(height = height, scale=1.5)
        children(i);
 }
 
 pyramidChildren(5)
    import(file = "xxx.svg", center = true, dpi = 96);

I have tried to use the basic svg (multiple paths) and also to group each path (with only itself) without changes in the result.

$\endgroup$
3
  • $\begingroup$ Have you tried using children() on the object? This should allow you to manipulate each letter separately. $\endgroup$
    – Mick
    Commented Dec 28, 2020 at 13:22
  • $\begingroup$ Thanks @Mick I didn't know about children(). I tried this after your comment, but it did not change the outcome... $\endgroup$
    – Oneira
    Commented Dec 28, 2020 at 17:54
  • 3
    $\begingroup$ children doesn't help. The import is a single child node not a sequence of components from the SVG. $\endgroup$ Commented Dec 30, 2020 at 19:06

4 Answers 4

6
$\begingroup$

Lame solution: creating stepped pyramid with offset. I realized that scale will not worked for motives with holes inside. Offset seems then more appropriate than scale for my application (creation of stamps)

It takes ages to render, but it could be enough for simple patterns. Any better solution are still welcome...

module buildPyramidalExtrude(height,maxOffset,nSlices){
    heightIncrement = height/nSlices;
    offsetIncrement = maxOffset/(nSlices-1);
    for(i=[1:nSlices])
        linear_extrude(height=i*heightIncrement)
              offset(r = maxOffset-(i-1)*offsetIncrement)
                children();
}

buildPyramidalExtrude(4,2.5,20)
   import(file = "Farm/cow.svg", center = true);

result

$\endgroup$
2
$\begingroup$

What you seem to want is not per-path scale but offset. This is an open PR in OpenSCAD and hopefully will be upstream soon.

$\endgroup$
1
  • $\begingroup$ Looking forward to see it in upstream! $\endgroup$
    – Oneira
    Commented Dec 29, 2020 at 18:42
1
$\begingroup$

One option is to use minkowski() to combine the svg with a cone. On the positive side, it gives a rather nice result, but the downsides are:

  • it's pretty slow
  • it fattens the bottom rather than shrinking the top, so depending on your needs you may have to invert the image, run minkowski, then invert again.

Another option is to convert to grayscale png and apply a blur with an external tool, then to import using surface() (the gray blur will become a nice slope). That will both fatten the bottom and shrink the top, but keeping only the top half should give the desired result.

$\endgroup$
1
$\begingroup$

Late to the question, but I'm working on a similar project as the question presents. My solution is to open the SVG file in Inkscape (version < 1.x) and use the Path to OpenSCAD extension to create a set of points for each entity.

The extension generates paths based on the desired extrusion height and places each set of points in its own module. In so doing, one can scale each individual entity and manipulate each one as desired.

Inkscape Extension for OpenSCAD use

Image from linked site.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .