discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

bend text

TL
Thomas Leonard Gertz
Sat, Jul 7, 2018 2:57 PM

I have tried this, but it doesnot make a perfect circle.
Howto?

st="Thomas Leonard Gertz";
width=140 ;
thickness=2 ;
chars=len(st)+1 ;
degrees=180 ;
for (i = [1:chars]) {
translate([ iwidth/chars,sin(idegrees/chars)*width/2,0])
linear_extrude(thickness)
text(st[i-1]);
}
translate([width/2,0,0])
rotate_extrude(angle=degrees) translate([width/2,0])
square([thickness,thickness]);


Thomas Leonard Gertz
Kerteminde, Danmark

Sent from: http://forum.openscad.org/

I have tried this, but it doesnot make a perfect circle. Howto? st="Thomas Leonard Gertz"; width=140 ; thickness=2 ; chars=len(st)+1 ; degrees=180 ; for (i = [1:chars]) { translate([ i*width/chars,sin(i*degrees/chars)*width/2,0]) linear_extrude(thickness) text(st[i-1]); } translate([width/2,0,0]) rotate_extrude(angle=degrees) translate([width/2,0]) square([thickness,thickness]); ----- Thomas Leonard Gertz Kerteminde, Danmark -- Sent from: http://forum.openscad.org/
HL
Hans L
Sat, Jul 7, 2018 3:19 PM

Well, the main issue is that you need a "cos" function on your x
coordinate to pair with the "sin" function on the y.  Besides that, do
you really want to only translate the letters into place, or would you
want them rotated along the curve?

I have a bearing mockup design that includes its own curved text
module which you could try if you want the letters orientation to
follow the curve:
https://www.thingiverse.com/thing:2419115/files

Hans

On Sat, Jul 7, 2018 at 9:58 AM Thomas Leonard Gertz thomas@leonard.dk wrote:

I have tried this, but it doesnot make a perfect circle.
Howto?

st="Thomas Leonard Gertz";
width=140 ;
thickness=2 ;
chars=len(st)+1 ;
degrees=180 ;
for (i = [1:chars]) {
translate([    iwidth/chars,sin(idegrees/chars)*width/2,0])
linear_extrude(thickness)
text(st[i-1]);
}
translate([width/2,0,0])
rotate_extrude(angle=degrees) translate([width/2,0])
square([thickness,thickness]);


Thomas Leonard Gertz
Kerteminde, Danmark

Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Well, the main issue is that you need a "cos" function on your x coordinate to pair with the "sin" function on the y. Besides that, do you really want to only translate the letters into place, or would you want them rotated along the curve? I have a bearing mockup design that includes its own curved text module which you could try if you want the letters orientation to follow the curve: https://www.thingiverse.com/thing:2419115/files Hans On Sat, Jul 7, 2018 at 9:58 AM Thomas Leonard Gertz <thomas@leonard.dk> wrote: > > I have tried this, but it doesnot make a perfect circle. > Howto? > > st="Thomas Leonard Gertz"; > width=140 ; > thickness=2 ; > chars=len(st)+1 ; > degrees=180 ; > for (i = [1:chars]) { > translate([ i*width/chars,sin(i*degrees/chars)*width/2,0]) > linear_extrude(thickness) > text(st[i-1]); > } > translate([width/2,0,0]) > rotate_extrude(angle=degrees) translate([width/2,0]) > square([thickness,thickness]); > > > > > ----- > Thomas Leonard Gertz > Kerteminde, Danmark > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
TL
Thomas Leonard Gertz
Sat, Jul 7, 2018 6:02 PM

I donot know why but it works without cos or sin only PI.


Thomas Leonard Gertz
Kerteminde, Danmark

Sent from: http://forum.openscad.org/

I donot know why but it works without cos or sin only PI. ----- Thomas Leonard Gertz Kerteminde, Danmark -- Sent from: http://forum.openscad.org/
C
cbernhardt
Sun, Jul 8, 2018 1:23 AM
Something like this? <http://forum.openscad.org/file/t1309/text_on_circle.jpg> -- Sent from: http://forum.openscad.org/
T
Troberg
Sun, Jul 8, 2018 6:04 PM

What you do is not a circle, it's half a sine wave.

Is it something like this you want to do?

st="Thomas Leonard Gertz";
width=140 ;
thickness=2 ;
chars=len(st)+1 ;
degrees=180 ;
for (i = [1:chars]) {
rotate([0,0,90-i*(180/chars)])
translate([0,width/2,0])
linear_extrude(thickness)
text(st[i-1],halign="center");
}

rotate_extrude(angle=degrees) translate([width/2,0])
square([thickness,thickness]);

--
Sent from: http://forum.openscad.org/

What you do is not a circle, it's half a sine wave. Is it something like this you want to do? st="Thomas Leonard Gertz"; width=140 ; thickness=2 ; chars=len(st)+1 ; degrees=180 ; for (i = [1:chars]) { rotate([0,0,90-i*(180/chars)]) translate([0,width/2,0]) linear_extrude(thickness) text(st[i-1],halign="center"); } rotate_extrude(angle=degrees) translate([width/2,0]) square([thickness,thickness]); -- Sent from: http://forum.openscad.org/
T
Troberg
Wed, Jul 11, 2018 8:14 AM

I turned it into a more generic module for this (works best with fixed width
fonts):

module
circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){

chars=len(mytext)+1;

for (i = [1:chars]) { 
		rotate([0,0,(top?1:-1)*(degrees/2-i*(degrees/chars))])
		translate([0,(top?1:-1)*radius-(top?0:textsize/2),0]) 
		//linear_extrude(thickness) 
		text(mytext[i-1],halign="center",font=myfont,size=textsize); 
} 

}

circletext("My text goes here",textsize=20,degrees=160,top=true);

circletext("Text can be underneath as
well",textsize=15,degrees=180,top=false);

--
Sent from: http://forum.openscad.org/

I turned it into a more generic module for this (works best with fixed width fonts): module circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){ chars=len(mytext)+1; for (i = [1:chars]) { rotate([0,0,(top?1:-1)*(degrees/2-i*(degrees/chars))]) translate([0,(top?1:-1)*radius-(top?0:textsize/2),0]) //linear_extrude(thickness) text(mytext[i-1],halign="center",font=myfont,size=textsize); } } circletext("My text goes here",textsize=20,degrees=160,top=true); circletext("Text can be underneath as well",textsize=15,degrees=180,top=false); -- Sent from: http://forum.openscad.org/
A
arnholm@arnholm.org
Wed, Jul 11, 2018 8:37 AM

On 2018-07-11 10:14, Troberg wrote:

I turned it into a more generic module for this (works best with fixed
width
fonts):

That's a quite nice result and a general solution.

A related challenge is to position text on non-flat surfaces, e.g. like
this
https://www.thingiverse.com/thing:2054654

But then the characters must also change shape (in the general case).

Carsten Arnholm

On 2018-07-11 10:14, Troberg wrote: > I turned it into a more generic module for this (works best with fixed > width > fonts): That's a quite nice result and a general solution. A related challenge is to position text on non-flat surfaces, e.g. like this https://www.thingiverse.com/thing:2054654 But then the characters must also change shape (in the general case). Carsten Arnholm
N
NateTG
Wed, Jul 11, 2018 5:46 PM

But then the characters must also change shape (in the general case).

Yeah, you need plastic transforms or userland access to geometry so you can
implement them youself.

It also gets more challenging when you deal with shapes like spheres that
have intrinsic curvature.

--
Sent from: http://forum.openscad.org/

> But then the characters must also change shape (in the general case). Yeah, you need plastic transforms or userland access to geometry so you can implement them youself. It also gets more challenging when you deal with shapes like spheres that have intrinsic curvature. -- Sent from: http://forum.openscad.org/
S
shadowwynd
Wed, Jul 11, 2018 6:50 PM

For the specific case of a cylinder, the text can be rotated and extruded.
For sufficiently large strings of text, the effect is pretty good as is, but
each character is still a linear segment.  Intersecting with a
high-resolution cylinder gives a fairly smooth curve over the text as a
whole.

module
circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){

    chars=len(mytext)+1; 
    
    for (i = [1:chars]) { 
                   

rotate([0,0,(top?1:-1)(degrees/2-i(degrees/chars))])

translate([0,(top?1:-1)*radius-(top?0:textsize/2),0])
rotate ([90,0,0])
linear_extrude(thickness)
text(mytext[i-1],halign="center",font=myfont,size=textsize);
}
}

intersection() {
cylinder (r=120, h=300, $fn=1000);
circletext("Text can be underneath as
well",textsize=15,degrees=180,top=false, thickness=20);
}

--
Sent from: http://forum.openscad.org/

For the specific case of a cylinder, the text can be rotated and extruded. For sufficiently large strings of text, the effect is pretty good as is, but each character is still a linear segment. Intersecting with a high-resolution cylinder gives a fairly smooth curve over the text as a whole. module circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){ chars=len(mytext)+1; for (i = [1:chars]) { rotate([0,0,(top?1:-1)*(degrees/2-i*(degrees/chars))]) translate([0,(top?1:-1)*radius-(top?0:textsize/2),0]) rotate ([90,0,0]) linear_extrude(thickness) text(mytext[i-1],halign="center",font=myfont,size=textsize); } } intersection() { cylinder (r=120, h=300, $fn=1000); circletext("Text can be underneath as well",textsize=15,degrees=180,top=false, thickness=20); } -- Sent from: http://forum.openscad.org/
J
jsc
Wed, Jul 11, 2018 7:31 PM

One minor improvement might be to use a technique I came up with to bend an
image into a cylinder: https://www.thingiverse.com/thing:322720

Instead of rotating each character separately, render the text into a flat
"stamp", then "emboss" that into a cylinder by rotating the cylinder and
advancing the plate a small amount each time. Intersecting with the cylinder
instead of differencing against it would produce a positive model.

This has the advantage that the error can be arbitrarily minimized, and you
get whatever kerning/character spacing benefits the text system provides
instead of having each character be spaced by an identical amount.

The downside is that it is computationally complex, and I don't think it is
possible to know the horizontal extent of the text string so that has to be
approximated somehow or adjusted until appropriate.

--
Sent from: http://forum.openscad.org/

One minor improvement might be to use a technique I came up with to bend an image into a cylinder: https://www.thingiverse.com/thing:322720 Instead of rotating each character separately, render the text into a flat "stamp", then "emboss" that into a cylinder by rotating the cylinder and advancing the plate a small amount each time. Intersecting with the cylinder instead of differencing against it would produce a positive model. This has the advantage that the error can be arbitrarily minimized, and you get whatever kerning/character spacing benefits the text system provides instead of having each character be spaced by an identical amount. The downside is that it is computationally complex, and I don't think it is possible to know the horizontal extent of the text string so that has to be approximated somehow or adjusted until appropriate. -- Sent from: http://forum.openscad.org/