We all know about the linear_extrude(...) function that turns 2d things into 3d things.

I sometimes have found myself wishing for a similar function which could make a more rounded, result.

Just to illustrate what I’m hoping to achieve, my dream solution would, given this 2d outline:

Capsule-shaped 2d outline.

would give me something like the following:

The same outline "pillowed" up into the third dimension.

Another angle of demonstrating the "back"/"bottom" is flat.

Just to further illustrate, the code I used to generate outline above:

hull() {
	for (i=[-1:1])
		translate([i*15, 0])
			circle(d=10);
}

And the “pillowed” version that shows the desired result giving the above outline:

$fn=64;
rotate([0, 90, 0])
	linear_extrude(30, center=true)
		scale([4, 10])
			difference() {
				circle(d=1);
				translate([0.5, 0])
					square(1, center=true);
			}
for (i = [-1, 1])
	translate([i*15, 0, 0])
		scale([10, 10, 4])
			difference() {
				sphere(d=1);
				translate([0, 0, -0.5])
					cube(1, center=true);
			}

The outline I actually want to pillow for my particular current use case looks like this:

A pattern in the style of a Talavera tile.

(Credit to this person on Printables for the Talavera tile pattern.)

I’m hoping there’s a way to do this I’m not thinking of, or a library I’m not familiar with. The example above makes an elliptical curve, but I’m not married to elliptical in particular. Anything somewhat similar would be fine.

Thanks in advance for any help!

  • TootSweet@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 days ago

    Thanks for the reply!

    So, it looks like Round Anything that you referred me to could do something like the kind of thing I’m looking for, but it does have a significant drawback. Namely that It looks like the polyRoundExtrude() requires a list of points and radii. All I have is an STL file that I can convert into an OpenSCAD 2d geometry with a projection(). To use polyRoundExtrude(), I’d basically have to rebuild the Talavera pattern from scratch using the Round Anything library. (Or maybe export to SVG and… write some custom code to convert that into an OpenSCAD syntax array? Still seems like a pain.)

    (One aside. I’d like to have an elliptical rounded corner rather than a circular one, but the above issue notwithstanding, that could be taken care of pretty easily with a bit of scaling magic.)

    With some searching and asking around elsewhere, I did find a bunch of other potential ways to accomplish something vaguely like I’m wanting:

    • BOSL2 - Might offer a solution to the second issue above. But it would similarly require rebuilding from scratch using BOSL2’s facilities rather than modifying from what I’ve already got. (Also, it’s pretty complex.)
    • roof() - It allows adding a chamfer. Only at a 45°, though. Definitely wouldn’t give me what I want (at least not on its own, but more on that later.) Also, roof() is only available in versions of OpenSCAD more recent than the latest release of OpenSCAD. So I’d have to use a recent development version. Not a deal breaker, but it doesn’t seem like it’ll do quite what I want anyway.
    • minkowski() - This one involves doing a linear_extrude(<a very small value>) and a minkowski() with a sphere or ellipsoid. I’d also need to subtract off a bulge on the underside, not that that would be any big deal in itself. The major downsides of this option are 1) it’s imprecise and 2) it’s really slow. Like really slow.

    But! I think I’ve found a solution I’m happy with. It also has drawbacks, but they’re drawbacks I’m more willing to live with than those from the above options.

    Ultimately, I’m planning to 3d-print the result on an FFF printer. (A Creality Ender 3 Pro and/or Ender 3 V2 Neo specifically.) I’m probably going to use the thinnest available layer height, which in Cura is 0.12mm.

    The reason I went into all of that is just to say that while I want it smooth, I don’t actually need it any smoother than my printer can handle. If it’s only smooth to a resolution of 0.12mm, that’s fine.

    So, the solution I came to is to construct the elliptical curve like a stepped pyramid, which layers 0.12mm thick. To make it elliptical, I just used the equation for a unit circle: y=sqrt(1-x^2). Here’s the code for this relatively simple solution:

    module pillow(height, delta) {
    	for (i = [0:floor(height/delta)])
    		linear_extrude(i*delta)
    			let(
    				x=i/floor(height/delta),
    				c=(1-sqrt(1-x^2))*height
    			)
    				offset(delta=-c)
    					children();
    }
    
    pillow(1.5, 0.12)
    	hull()
    		for (i=[-1:1])
    			translate([i*15, 0])
    				circle(d=10);
    

    And the result looks like:

    The first example in the original post with the stepped pyramid elliptical "pillowing" effect applied. It's "ribbed" or "stepped" with only right-angles, but it does a decent job of approximating an elliptical curve if you're good with ignoring any detail 0.12mm or smaller in size.

    The Talavera pattern with the same stepped effect applied. Looks kinda cool if I do say so myself.

    Drawbacks:

    • This solution is a little slow. Nowhere near as slow as the minkowski() solution, but kinda slow.
    • The stepping probably better be tailored to your specific planned layer height. Which means if you want to reprint with a different layer height, you’re probably best off to start by making a change (a small change, but a change none the less) to the .scad file.

    Just as one final point, while I haven’t yet had occasion to mess with roof() to really know the details of how it works and what it can do, I think the solution I came up with could be adapted to use roof() to make a much smoother and less stepped look. (Only in a version of OpenSCAD that supports roof() of course.)

    That’s it. I figured I’d detail my solution in case it’d help anyone else.

    Thanks again for your input!

    • sp3ctr4l
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      4 days ago

      Ah… oops.

      I did not realize that basically Step 0 did not work, due to your input data format being incompatible with the actual function…

      But, your ‘stepped pyramid’ solution does work!

      I am not at all familiar with the actual material you are printing… but I did have a friend who got into thermoplastic 3D printing over a decade ago, when it was all pretty new.

      For some shapes, he would do a similar approach to your stepped pyramid approach, and then just physically sand them down to smoothness by hand, with sand paper and … some kind of small, dremel style sanding tool, something like this.

      You just have to enlarge the whole shape such that you can sand it down to the actual desired size/shape.

      But that would probably be pretty time consuming with your pattern here, as its something like 30 different pieces… and with pieces this small, it may be impractical if you are not pretty dextrous.

      • TootSweet@lemmy.worldOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 days ago

        I’m planning to print in PLA. Aside from sanding, I’ve heard primer/filler and even wood filler can be used to help hide layer lines. Also, I’m planning to paint the result with something kindof patterned/blotchy to help obscure the layer lines.

        I don’t have stringent tolerances or anything, so I don’t expect I’ll need to build it up to account for material removed by sanding or anything. My ultimate goal is to make tiles for the backsplash over my stove. The back (bottom for printing orientation) needs to be roughly as flat as my wall. The front(/top), aside from the features, needs to be sufficiently flat and of consistent thickness as to not stand out to the eye from a couple of feet away. And they need to be square enough to tile nicely on the wall. Aside from that, if sanding makes my 2mm thick features into 1.9mm thick features, that’s no real problem for my application.

        You may have a point about the hard-to-reach corners. I’m hoping the spray primer/filler will help a lot with that.