discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Engrave text in a curved surface?

A
amundsen
Wed, Apr 14, 2021 7:58 AM

Hello,

It's easy to engrave text in a planar surface using difference() and
linear_extrude().

Is there any way to achieve a similar engraving in a curved surface, for
instance the surface of a cylinder (with the bottom of the engraving
parallel to the surface) ?

Thank you in advance.

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

Hello, It's easy to engrave text in a planar surface using difference() and linear_extrude(). Is there any way to achieve a similar engraving in a curved surface, for instance the surface of a cylinder (with the bottom of the engraving parallel to the surface) ? Thank you in advance. -- Sent from: http://forum.openscad.org/
W
Whosawhatsis
Wed, Apr 14, 2021 8:04 AM

If you don't care about your engraving wrapping around surface's curvature, only the depth being consistent, you can subtract a smaller version of the cylinder from the thing you're subtracting.
On Apr 14, 2021, 00:59 -0700, amundsen roald.baudoux@brutele.be, wrote:

Hello,

It's easy to engrave text in a planar surface using difference() and linear_extrude().

Is there any way to achieve a similar engraving in a curved surface, for instance the surface of a cylinder (with the bottom of the engraving parallel to the surface) ?

Thank you in advance.
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If you don't care about your engraving wrapping around surface's curvature, only the depth being consistent, you can subtract a smaller version of the cylinder from the thing you're subtracting. On Apr 14, 2021, 00:59 -0700, amundsen <roald.baudoux@brutele.be>, wrote: > Hello, > > It's easy to engrave text in a planar surface using difference() and linear_extrude(). > > Is there any way to achieve a similar engraving in a curved surface, for instance the surface of a cylinder (with the bottom of the engraving parallel to the surface) ? > > Thank you in advance. > Sent from the OpenSCAD mailing list archive at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
FV
Frank van der Hulst
Wed, Apr 14, 2021 8:24 AM

https://www.thingiverse.com/thing:1668883

On Wed, 14 Apr 2021, 8:04 pm Whosawhatsis, whosawhatsis@gmail.com wrote:

If you don't care about your engraving wrapping around surface's
curvature, only the depth being consistent, you can subtract a smaller
version of the cylinder from the thing you're subtracting.
On Apr 14, 2021, 00:59 -0700, amundsen roald.baudoux@brutele.be, wrote:

Hello,

It's easy to engrave text in a planar surface using difference() and
linear_extrude().

Is there any way to achieve a similar engraving in a curved surface, for
instance the surface of a cylinder (with the bottom of the engraving
parallel to the surface) ?

Thank you in advance.

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

https://www.thingiverse.com/thing:1668883 On Wed, 14 Apr 2021, 8:04 pm Whosawhatsis, <whosawhatsis@gmail.com> wrote: > If you don't care about your engraving wrapping around surface's > curvature, only the depth being consistent, you can subtract a smaller > version of the cylinder from the thing you're subtracting. > On Apr 14, 2021, 00:59 -0700, amundsen <roald.baudoux@brutele.be>, wrote: > > Hello, > > It's easy to engrave text in a planar surface using difference() and > linear_extrude(). > > Is there any way to achieve a similar engraving in a curved surface, for > instance the surface of a cylinder (with the bottom of the engraving > parallel to the surface) ? > > Thank you in advance. > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
CA
Carsten Arnholm
Wed, Apr 14, 2021 9:23 AM

On 14.04.2021 09:58, amundsen wrote:

Hello,

It's easy to engrave text in a planar surface using difference() and
linear_extrude().

Is there any way to achieve a similar engraving in a curved surface, for
instance the surface of a cylinder (with the bottom of the engraving
parallel to the surface) ?

I don't think there is a direct way to generally do that in OpenSCAD,
but you can combine OpenSCAD with other tools to do it.

Let us say you use OpenSCAD to model a cylinder and another OpenSCAD
session to model the text to be engraved:

cylinder.scad:

cylinder(r=30,h=30);

cylinder_text.scad

linear_extrude(5)
text("Text on a cylinder");

To engrave the text on the cylinder, you can do:

1 OpenSCAD: cylinder.scad => Save as 'cylinder.obj'

2 OpenSCAD: cylinder_text.scad => save as 'cylinder_text.obj'

3 Remesh the 'cylinder_text.obj' file to max 2mm size triangles.
To do this, use 'polyfix', a console application included with AngelCAD

$ polyfix -remesh=2.0 -dtol=0.001 -overwrite ./cylinder_text.obj -out=*.obj

The result is a new version of 'cylinder_text.obj' with denser triangle
mesh, to be used in step 4 below.

4 AngelCAD: cylinder_engrave.as => cylinder_engrave.stl
This script imports the 2 .obj files created with OpenSCAD, wraps the
'cylinder_text.obj' around a r=28mm cylinder and performs the engraving
by subtracting it from 'cylinder.obj'

Files and more details here, including final engraved cylinder
https://gist.github.com/arnholm/de12d1768cc552a416a6f9edebd0a81c

https://github.com/arnholm/angelcad/releases

Regards
Carsten Arnholm

On 14.04.2021 09:58, amundsen wrote: > Hello, > > It's easy to engrave text in a planar surface using difference() and > linear_extrude(). > > Is there any way to achieve a similar engraving in a curved surface, for > instance the surface of a cylinder (with the bottom of the engraving > parallel to the surface) ? I don't think there is a direct way to generally do that in OpenSCAD, but you can combine OpenSCAD with other tools to do it. Let us say you use OpenSCAD to model a cylinder and another OpenSCAD session to model the text to be engraved: cylinder.scad: ------------- cylinder(r=30,h=30); cylinder_text.scad ------------------ linear_extrude(5) text("Text on a cylinder"); To engrave the text on the cylinder, you can do: 1 OpenSCAD: cylinder.scad => Save as 'cylinder.obj' 2 OpenSCAD: cylinder_text.scad => save as 'cylinder_text.obj' 3 Remesh the 'cylinder_text.obj' file to max 2mm size triangles. To do this, use 'polyfix', a console application included with AngelCAD $ polyfix -remesh=2.0 -dtol=0.001 -overwrite ./cylinder_text.obj -out=*.obj The result is a new version of 'cylinder_text.obj' with denser triangle mesh, to be used in step 4 below. 4 AngelCAD: cylinder_engrave.as => cylinder_engrave.stl This script imports the 2 .obj files created with OpenSCAD, wraps the 'cylinder_text.obj' around a r=28mm cylinder and performs the engraving by subtracting it from 'cylinder.obj' Files and more details here, including final engraved cylinder https://gist.github.com/arnholm/de12d1768cc552a416a6f9edebd0a81c https://github.com/arnholm/angelcad/releases Regards Carsten Arnholm
N
NateTG
Wed, Apr 14, 2021 2:09 PM

With a surface that's as simple as a cylinder, it's possible to use boolean
operations to cut wedges out of extruded text and then assemble them into a
curve, but the geometry engine will take a while to chew on something like
that.

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

With a surface that's as simple as a cylinder, it's possible to use boolean operations to cut wedges out of extruded text and then assemble them into a curve, but the geometry engine will take a while to chew on something like that. -- Sent from: http://forum.openscad.org/
AC
A. Craig West
Wed, Apr 14, 2021 2:48 PM

I have code that does this, but it is VERY slow on any significant amounts
of text (The bend module is the key one, the rest of it sets up what to
bend):

module inscribe2d(depth, baseOffset, width = 0, height = 0) {
translate([0, 0, baseOffset - depth]) {
linear_extrude(depth, center = false) {
if (width > 0 || height > 0) {
resize([width, height], auto=[true, true, false]) {
children();
}
} else {
children();
}
}
}
}

module monogram(text, font, depth, baseOffset, width = 0, height = 0) {
inscribe2d(depth, baseOffset, width, height) {
if (is_undef(font)) {
text(text, size = 10, valign = "center", halign = "center");
} else {
text(text, font = font, size = 10, valign = "center", halign =
"center");
}
}
}

module bend(radius, angleOffset = 0) {
stepAngle = 360 / $fn;
stepWidth = 2 * PI * radius / $fn;
union() {
for (step = [-$fn : $fn]) {
angle = step * stepAngle + angleOffset;
offset = step * stepWidth;
translate([0, 0, radius]) {
rotate([0, -angle, 0]) {
translate([-offset, 0, -radius]) {
intersection() {
children();
translate([offset, 0, 0]) {
cube(size = [stepWidth, stepWidth * $fn, stepWidth * $fn],
center = true);
}
}
}
}
}
}
}
}

module labeledDisc(radius, thickness, label = undef) {
difference() {
rotate([0, 0, 180 / $fn]) {
cylinder(r = radius, h = thickness, center = true);
}
if (SHOW_TEXT && !is_undef(label)) {
rotate([90, 0, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth = 2.01,
baseOffset = 2);
}
}
}
}
rotate([90, 180, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth = 2.01,
baseOffset = 2);
}
}
}
}
}
}
}

On Wed, Apr 14, 2021 at 10:09 AM NateTG nate-openscadforum@pedantic.org
wrote:

With a surface that's as simple as a cylinder, it's possible to use
boolean operations to cut wedges out of extruded text and then assemble
them into a curve, but the geometry engine will take a while to chew on
something like that.


Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I have code that does this, but it is VERY slow on any significant amounts of text (The bend module is the key one, the rest of it sets up what to bend): module inscribe2d(depth, baseOffset, width = 0, height = 0) { translate([0, 0, baseOffset - depth]) { linear_extrude(depth, center = false) { if (width > 0 || height > 0) { resize([width, height], auto=[true, true, false]) { children(); } } else { children(); } } } } module monogram(text, font, depth, baseOffset, width = 0, height = 0) { inscribe2d(depth, baseOffset, width, height) { if (is_undef(font)) { text(text, size = 10, valign = "center", halign = "center"); } else { text(text, font = font, size = 10, valign = "center", halign = "center"); } } } module bend(radius, angleOffset = 0) { stepAngle = 360 / $fn; stepWidth = 2 * PI * radius / $fn; union() { for (step = [-$fn : $fn]) { angle = step * stepAngle + angleOffset; offset = step * stepWidth; translate([0, 0, radius]) { rotate([0, -angle, 0]) { translate([-offset, 0, -radius]) { intersection() { children(); translate([offset, 0, 0]) { cube(size = [stepWidth, stepWidth * $fn, stepWidth * $fn], center = true); } } } } } } } } module labeledDisc(radius, thickness, label = undef) { difference() { rotate([0, 0, 180 / $fn]) { cylinder(r = radius, h = thickness, center = true); } if (SHOW_TEXT && !is_undef(label)) { rotate([90, 0, -90]) { translate([0, 0, -radius]) { bend(radius = radius, angleOffset = 90) { scale([-1, 1, 1]) { monogram(label, height = (thickness * 0.8), depth = 2.01, baseOffset = 2); } } } } rotate([90, 180, -90]) { translate([0, 0, -radius]) { bend(radius = radius, angleOffset = 90) { scale([-1, 1, 1]) { monogram(label, height = (thickness * 0.8), depth = 2.01, baseOffset = 2); } } } } } } } On Wed, Apr 14, 2021 at 10:09 AM NateTG <nate-openscadforum@pedantic.org> wrote: > With a surface that's as simple as a cylinder, it's possible to use > boolean operations to cut wedges out of extruded text and then assemble > them into a curve, but the geometry engine will take a while to chew on > something like that. > > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
MV
Maurice van Peursem
Wed, Apr 14, 2021 8:55 PM

This looks very good, but could you please provide a working example
call? It is not completely clear to me how to use your code.

Cheers,
Maurice

I have code that does this, but it is VERY slow on any significant
amounts of text (The bend module is the key one, the rest of it sets
up what to bend):

module inscribe2d(depth, baseOffset, width = 0, height = 0) {
translate([0, 0, baseOffset - depth]) {
linear_extrude(depth, center = false) {
if (width > 0 || height > 0) {
resize([width, height], auto=[true, true, false]) {
children();
}
} else {
children();
}
}
}
}

module monogram(text, font, depth, baseOffset, width = 0, height = 0) {
inscribe2d(depth, baseOffset, width, height) {
if (is_undef(font)) {
text(text, size = 10, valign = "center", halign = "center");
} else {
text(text, font = font, size = 10, valign = "center", halign =
"center");
}
}
}

module bend(radius, angleOffset = 0) {
stepAngle = 360 / $fn;
stepWidth = 2 * PI * radius / $fn;
union() {
for (step = [-$fn : $fn]) {
angle = step * stepAngle + angleOffset;
offset = step * stepWidth;
translate([0, 0, radius]) {
rotate([0, -angle, 0]) {
translate([-offset, 0, -radius]) {
intersection() {
children();
translate([offset, 0, 0]) {
cube(size = [stepWidth, stepWidth * $fn, stepWidth *
$fn], center = true);
}
}
}
}
}
}
}
}

module labeledDisc(radius, thickness, label = undef) {
difference() {
rotate([0, 0, 180 / $fn]) {
cylinder(r = radius, h = thickness, center = true);
}
if (SHOW_TEXT && !is_undef(label)) {
rotate([90, 0, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
rotate([90, 180, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
}
}
}

This looks very good, but could you please provide a working example call? It is not completely clear to me how to use your code. Cheers, Maurice >I have code that does this, but it is VERY slow on any significant >amounts of text (The bend module is the key one, the rest of it sets >up what to bend): > >module inscribe2d(depth, baseOffset, width = 0, height = 0) { > translate([0, 0, baseOffset - depth]) { > linear_extrude(depth, center = false) { > if (width > 0 || height > 0) { > resize([width, height], auto=[true, true, false]) { > children(); > } > } else { > children(); > } > } > } >} > > >module monogram(text, font, depth, baseOffset, width = 0, height = 0) { > inscribe2d(depth, baseOffset, width, height) { > if (is_undef(font)) { > text(text, size = 10, valign = "center", halign = "center"); > } else { > text(text, font = font, size = 10, valign = "center", halign = >"center"); > } > } >} > > >module bend(radius, angleOffset = 0) { > stepAngle = 360 / $fn; > stepWidth = 2 * PI * radius / $fn; > union() { > for (step = [-$fn : $fn]) { > angle = step * stepAngle + angleOffset; > offset = step * stepWidth; > translate([0, 0, radius]) { > rotate([0, -angle, 0]) { > translate([-offset, 0, -radius]) { > intersection() { > children(); > translate([offset, 0, 0]) { > cube(size = [stepWidth, stepWidth * $fn, stepWidth * >$fn], center = true); > } > } > } > } > } > } > } >} > >module labeledDisc(radius, thickness, label = undef) { > difference() { > rotate([0, 0, 180 / $fn]) { > cylinder(r = radius, h = thickness, center = true); > } > if (SHOW_TEXT && !is_undef(label)) { > rotate([90, 0, -90]) { > translate([0, 0, -radius]) { > bend(radius = radius, angleOffset = 90) { > scale([-1, 1, 1]) { > monogram(label, height = (thickness * 0.8), depth = >2.01, baseOffset = 2); > } > } > } > } > rotate([90, 180, -90]) { > translate([0, 0, -radius]) { > bend(radius = radius, angleOffset = 90) { > scale([-1, 1, 1]) { > monogram(label, height = (thickness * 0.8), depth = >2.01, baseOffset = 2); > } > } > } > } > } > } >} >
AC
A. Craig West
Wed, Apr 14, 2021 9:50 PM

A better version of it would be in the attached bend.scad. I had at least
one bit of code leftover from the project I stole it from, and it depended
on $fn being set, which is not always the case... the render() call
wrapping the actual call to labeledDisc helps a lot for the speed, although
it is still not blazingly fast by any means.

On Wed, Apr 14, 2021 at 4:55 PM Maurice van Peursem openscad@vanpeursem.net
wrote:

This looks very good, but could you please provide a working example
call? It is not completely clear to me how to use your code.

Cheers,
Maurice

I have code that does this, but it is VERY slow on any significant
amounts of text (The bend module is the key one, the rest of it sets
up what to bend):

module inscribe2d(depth, baseOffset, width = 0, height = 0) {
translate([0, 0, baseOffset - depth]) {
linear_extrude(depth, center = false) {
if (width > 0 || height > 0) {
resize([width, height], auto=[true, true, false]) {
children();
}
} else {
children();
}
}
}
}

module monogram(text, font, depth, baseOffset, width = 0, height = 0) {
inscribe2d(depth, baseOffset, width, height) {
if (is_undef(font)) {
text(text, size = 10, valign = "center", halign = "center");
} else {
text(text, font = font, size = 10, valign = "center", halign =
"center");
}
}
}

module bend(radius, angleOffset = 0) {
stepAngle = 360 / $fn;
stepWidth = 2 * PI * radius / $fn;
union() {
for (step = [-$fn : $fn]) {
angle = step * stepAngle + angleOffset;
offset = step * stepWidth;
translate([0, 0, radius]) {
rotate([0, -angle, 0]) {
translate([-offset, 0, -radius]) {
intersection() {
children();
translate([offset, 0, 0]) {
cube(size = [stepWidth, stepWidth * $fn, stepWidth *
$fn], center = true);
}
}
}
}
}
}
}
}

module labeledDisc(radius, thickness, label = undef) {
difference() {
rotate([0, 0, 180 / $fn]) {
cylinder(r = radius, h = thickness, center = true);
}
if (SHOW_TEXT && !is_undef(label)) {
rotate([90, 0, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
rotate([90, 180, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
}
}
}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

A better version of it would be in the attached bend.scad. I had at least one bit of code leftover from the project I stole it from, and it depended on $fn being set, which is not always the case... the render() call wrapping the actual call to labeledDisc helps a lot for the speed, although it is still not blazingly fast by any means. On Wed, Apr 14, 2021 at 4:55 PM Maurice van Peursem <openscad@vanpeursem.net> wrote: > This looks very good, but could you please provide a working example > call? It is not completely clear to me how to use your code. > > Cheers, > Maurice > > >I have code that does this, but it is VERY slow on any significant > >amounts of text (The bend module is the key one, the rest of it sets > >up what to bend): > > > >module inscribe2d(depth, baseOffset, width = 0, height = 0) { > > translate([0, 0, baseOffset - depth]) { > > linear_extrude(depth, center = false) { > > if (width > 0 || height > 0) { > > resize([width, height], auto=[true, true, false]) { > > children(); > > } > > } else { > > children(); > > } > > } > > } > >} > > > > > >module monogram(text, font, depth, baseOffset, width = 0, height = 0) { > > inscribe2d(depth, baseOffset, width, height) { > > if (is_undef(font)) { > > text(text, size = 10, valign = "center", halign = "center"); > > } else { > > text(text, font = font, size = 10, valign = "center", halign = > >"center"); > > } > > } > >} > > > > > >module bend(radius, angleOffset = 0) { > > stepAngle = 360 / $fn; > > stepWidth = 2 * PI * radius / $fn; > > union() { > > for (step = [-$fn : $fn]) { > > angle = step * stepAngle + angleOffset; > > offset = step * stepWidth; > > translate([0, 0, radius]) { > > rotate([0, -angle, 0]) { > > translate([-offset, 0, -radius]) { > > intersection() { > > children(); > > translate([offset, 0, 0]) { > > cube(size = [stepWidth, stepWidth * $fn, stepWidth * > >$fn], center = true); > > } > > } > > } > > } > > } > > } > > } > >} > > > >module labeledDisc(radius, thickness, label = undef) { > > difference() { > > rotate([0, 0, 180 / $fn]) { > > cylinder(r = radius, h = thickness, center = true); > > } > > if (SHOW_TEXT && !is_undef(label)) { > > rotate([90, 0, -90]) { > > translate([0, 0, -radius]) { > > bend(radius = radius, angleOffset = 90) { > > scale([-1, 1, 1]) { > > monogram(label, height = (thickness * 0.8), depth = > >2.01, baseOffset = 2); > > } > > } > > } > > } > > rotate([90, 180, -90]) { > > translate([0, 0, -radius]) { > > bend(radius = radius, angleOffset = 90) { > > scale([-1, 1, 1]) { > > monogram(label, height = (thickness * 0.8), depth = > >2.01, baseOffset = 2); > > } > > } > > } > > } > > } > > } > >} > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
AC
A. Craig West
Wed, Apr 14, 2021 10:02 PM

I will note that I just noticed that the code doesn't work proper if $fn is
less than 8, I am still working out what I did wrong

On Wed, Apr 14, 2021 at 5:50 PM A. Craig West acraigwest@gmail.com wrote:

A better version of it would be in the attached bend.scad. I had at least
one bit of code leftover from the project I stole it from, and it depended
on $fn being set, which is not always the case... the render() call
wrapping the actual call to labeledDisc helps a lot for the speed, although
it is still not blazingly fast by any means.

On Wed, Apr 14, 2021 at 4:55 PM Maurice van Peursem <
openscad@vanpeursem.net> wrote:

This looks very good, but could you please provide a working example
call? It is not completely clear to me how to use your code.

Cheers,
Maurice

I have code that does this, but it is VERY slow on any significant
amounts of text (The bend module is the key one, the rest of it sets
up what to bend):

module inscribe2d(depth, baseOffset, width = 0, height = 0) {
translate([0, 0, baseOffset - depth]) {
linear_extrude(depth, center = false) {
if (width > 0 || height > 0) {
resize([width, height], auto=[true, true, false]) {
children();
}
} else {
children();
}
}
}
}

module monogram(text, font, depth, baseOffset, width = 0, height = 0) {
inscribe2d(depth, baseOffset, width, height) {
if (is_undef(font)) {
text(text, size = 10, valign = "center", halign = "center");
} else {
text(text, font = font, size = 10, valign = "center", halign =
"center");
}
}
}

module bend(radius, angleOffset = 0) {
stepAngle = 360 / $fn;
stepWidth = 2 * PI * radius / $fn;
union() {
for (step = [-$fn : $fn]) {
angle = step * stepAngle + angleOffset;
offset = step * stepWidth;
translate([0, 0, radius]) {
rotate([0, -angle, 0]) {
translate([-offset, 0, -radius]) {
intersection() {
children();
translate([offset, 0, 0]) {
cube(size = [stepWidth, stepWidth * $fn, stepWidth *
$fn], center = true);
}
}
}
}
}
}
}
}

module labeledDisc(radius, thickness, label = undef) {
difference() {
rotate([0, 0, 180 / $fn]) {
cylinder(r = radius, h = thickness, center = true);
}
if (SHOW_TEXT && !is_undef(label)) {
rotate([90, 0, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
rotate([90, 180, -90]) {
translate([0, 0, -radius]) {
bend(radius = radius, angleOffset = 90) {
scale([-1, 1, 1]) {
monogram(label, height = (thickness * 0.8), depth =
2.01, baseOffset = 2);
}
}
}
}
}
}
}


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I will note that I just noticed that the code doesn't work proper if $fn is less than 8, I am still working out what I did wrong On Wed, Apr 14, 2021 at 5:50 PM A. Craig West <acraigwest@gmail.com> wrote: > A better version of it would be in the attached bend.scad. I had at least > one bit of code leftover from the project I stole it from, and it depended > on $fn being set, which is not always the case... the render() call > wrapping the actual call to labeledDisc helps a lot for the speed, although > it is still not blazingly fast by any means. > > On Wed, Apr 14, 2021 at 4:55 PM Maurice van Peursem < > openscad@vanpeursem.net> wrote: > >> This looks very good, but could you please provide a working example >> call? It is not completely clear to me how to use your code. >> >> Cheers, >> Maurice >> >> >I have code that does this, but it is VERY slow on any significant >> >amounts of text (The bend module is the key one, the rest of it sets >> >up what to bend): >> > >> >module inscribe2d(depth, baseOffset, width = 0, height = 0) { >> > translate([0, 0, baseOffset - depth]) { >> > linear_extrude(depth, center = false) { >> > if (width > 0 || height > 0) { >> > resize([width, height], auto=[true, true, false]) { >> > children(); >> > } >> > } else { >> > children(); >> > } >> > } >> > } >> >} >> > >> > >> >module monogram(text, font, depth, baseOffset, width = 0, height = 0) { >> > inscribe2d(depth, baseOffset, width, height) { >> > if (is_undef(font)) { >> > text(text, size = 10, valign = "center", halign = "center"); >> > } else { >> > text(text, font = font, size = 10, valign = "center", halign = >> >"center"); >> > } >> > } >> >} >> > >> > >> >module bend(radius, angleOffset = 0) { >> > stepAngle = 360 / $fn; >> > stepWidth = 2 * PI * radius / $fn; >> > union() { >> > for (step = [-$fn : $fn]) { >> > angle = step * stepAngle + angleOffset; >> > offset = step * stepWidth; >> > translate([0, 0, radius]) { >> > rotate([0, -angle, 0]) { >> > translate([-offset, 0, -radius]) { >> > intersection() { >> > children(); >> > translate([offset, 0, 0]) { >> > cube(size = [stepWidth, stepWidth * $fn, stepWidth * >> >$fn], center = true); >> > } >> > } >> > } >> > } >> > } >> > } >> > } >> >} >> > >> >module labeledDisc(radius, thickness, label = undef) { >> > difference() { >> > rotate([0, 0, 180 / $fn]) { >> > cylinder(r = radius, h = thickness, center = true); >> > } >> > if (SHOW_TEXT && !is_undef(label)) { >> > rotate([90, 0, -90]) { >> > translate([0, 0, -radius]) { >> > bend(radius = radius, angleOffset = 90) { >> > scale([-1, 1, 1]) { >> > monogram(label, height = (thickness * 0.8), depth = >> >2.01, baseOffset = 2); >> > } >> > } >> > } >> > } >> > rotate([90, 180, -90]) { >> > translate([0, 0, -radius]) { >> > bend(radius = radius, angleOffset = 90) { >> > scale([-1, 1, 1]) { >> > monogram(label, height = (thickness * 0.8), depth = >> >2.01, baseOffset = 2); >> > } >> > } >> > } >> > } >> > } >> > } >> >} >> > >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >
DE
David Eccles (gringer)
Thu, Apr 15, 2021 9:55 AM

cacb wrote

I don't think there is a direct way to generally do that in OpenSCAD,
but you can combine OpenSCAD with other tools to do it.

Here's my attempt:

====

use <alphabet_points.scad>;
use <path_extrude.scad>;

myPath = [[58,0,0], [62,0,0]];

module extrudeLetter(pointSets, extrudeType, path){
for(ps = pointSets){
mapExtrude(extrudeType, ps, path, $fn=5);
}
}

rotate([0,0,-$t * 360]){
difference(){
cylinder(r=60, h=100, $fn=100, center=true);
for(ltl = [0, 1]){
lArr = ["ENGRAVED", "TEXT"][ltl];
sw = strLen(lettersToNumbers(lArr))2;
cCirc = 2 * PI * 60;
for(lp = [0:(len(lArr)-1)]){
rotate([0,0,lp
16 -(sw/cCirc * 180)]) translate([0,0,-ltl*30]){
extrudeLetter(ltrPoints(lettersToNumbers(lArr[lp])[0])*2,
"radialCylinder", myPath);
}
}
}
}
}

====

This uses my point-based OpenSCAD font (only capital letters at the moment):

https://www.thingiverse.com/thing:4826453

And my guided path extrusion code (which I just adapted now to do a radial
extrude):

https://www.thingiverse.com/thing:4824085

This doesn't render properly in preview mode (presumably due to the issues
with assuming a curved surface, i.e. the end caps of the extrusion, is
flat), but seems to work okay in the fully-rendered mode.

http://forum.openscad.org/file/t452/text_engraved.png

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

cacb wrote > I don't think there is a direct way to generally do that in OpenSCAD, > but you can combine OpenSCAD with other tools to do it. Here's my attempt: ==== use <alphabet_points.scad>; use <path_extrude.scad>; myPath = [[58,0,0], [62,0,0]]; module extrudeLetter(pointSets, extrudeType, path){ for(ps = pointSets){ mapExtrude(extrudeType, ps, path, $fn=5); } } rotate([0,0,-$t * 360]){ difference(){ cylinder(r=60, h=100, $fn=100, center=true); for(ltl = [0, 1]){ lArr = ["ENGRAVED", "TEXT"][ltl]; sw = strLen(lettersToNumbers(lArr))*2; cCirc = 2 * PI * 60; for(lp = [0:(len(lArr)-1)]){ rotate([0,0,lp*16 -(sw/cCirc * 180)]) translate([0,0,-ltl*30]){ extrudeLetter(ltrPoints(lettersToNumbers(lArr[lp])[0])*2, "radialCylinder", myPath); } } } } } ==== This uses my point-based OpenSCAD font (only capital letters at the moment): https://www.thingiverse.com/thing:4826453 And my guided path extrusion code (which I just adapted now to do a radial extrude): https://www.thingiverse.com/thing:4824085 This doesn't render properly in preview mode (presumably due to the issues with assuming a curved surface, i.e. the end caps of the extrusion, is flat), but seems to work okay in the fully-rendered mode. <http://forum.openscad.org/file/t452/text_engraved.png> -- Sent from: http://forum.openscad.org/