2
$\begingroup$

I want to put relief text on curved surface but can't find way to do that in OpenSCAD. I'm aware it's possible to bend text in Blender and then import stl, but I don't like this workflow. I found sort of working solution but it's not perfect.

$fn=50;

module bend_text(caption, angle, text_height, text_width, text_depth, steps=10, k=1) {
    dh = text_height / steps;
    r = text_height / (angle * PI / 180);
    h0 = - text_height / 2;
    translate([0, 0, -r])
    rotate([angle / 2, 0, 0])
    for(i=[0:steps-1]) {
        rotate([-i * angle/steps, 0, 0])
        translate([0, -(dh * i + h0), r / k])
        intersection() {
            linear_extrude(text_depth) 
                text(caption, valign="center", halign="center");
            translate([0, dh * i + h0, 0]) 
                cube([text_width, dh, text_width], center=true);
        }
    }
}

bend_text("test", angle=90, text_height=9, text_width=30, text_depth=1, steps=10, k=1.1);

test

Is there better way?

$\endgroup$
1
  • $\begingroup$ This is a 3DPrinting stack not a CAD stack, mentioning the relevance to 3D printing is required, from on-topic :If a CAD question is related to 3D printing then it is on-topic. However, general CAD questions, unrelated to 3D printing, are not on-topic. Very interesting question though! Mentioning that bending the text is required when text is projected onto small radii else there might be gaps under the letters that prevent proper printing. $\endgroup$
    – 0scar
    May 16 at 11:46

2 Answers 2

1
$\begingroup$

The workflow you're using is the only way I'm aware of, and it's at least respectable. You can abstract it as a module to apply to arbitrary children to make it somewhat less ugly and more reusable.

In theory, I think it should be possible to make an openscad transformation (in openscad itself, not in the scad language) that applies to arbitrary 3D objects by performing a 2D conformal map in each cross section perpendicular to a given axis, to achieve effects like this, without the possibility of breaking geometry. But I'm not aware of anyone working on that. I'll probably propose it at some point, and hopefully it won't get shot down as mathematically unsound (which it might be; I'm not sure).

$\endgroup$
1
$\begingroup$

I can't say if this is better than your method, but it is a library resource specific to your requirements.

Text_on OpenSCAD

The library covers various shapes, including cylindrical:

text on cylinders

Image from linked site. Also from the site: "Only works with OpenSCAD v 2014.xx and later..."

$\endgroup$
3
  • 1
    $\begingroup$ As far as I can see it doesn't bend characters, it just puts each character on it's own plane, that's not what I want. $\endgroup$ May 12 at 22:04
  • 1
    $\begingroup$ That's a distinction I overlooked, thanks for the clarification. It makes your creation all the more impressive. Is there a means to remove the slices from the creation? $\endgroup$
    – fred_dot_u
    May 12 at 22:45
  • 1
    $\begingroup$ yes, slices can be removed, I have used cube to split text to pieces, I should've used triangle prism $\endgroup$ May 13 at 7:43

You must log in to answer this question.

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