Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

For now you should send emails, people will see them, discuss@lists.openscad.org.

Engrave text in a curved surface?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Engrave text in a curved surface?

amundsen
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 [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

Whosawhatsis
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 <[hidden email]>, 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

frankv

On Wed, 14 Apr 2021, 8:04 pm Whosawhatsis, <[hidden email]> 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 <[hidden email]>, 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 [hidden email]
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

cacb
In reply to this post by amundsen
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
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

NateTG
In reply to this post by amundsen
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 at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

acwest
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

Maurice van Peursem
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 [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

acwest
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 <[hidden email]> 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

bend.scad (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

acwest
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 <[hidden email]> 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 <[hidden email]> 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

David Eccles (gringer)
In reply to this post by cacb
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.

ENGRAVED TEXT, wrapped around and engraved into a cylinder

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

David Eccles (gringer)
In reply to this post by amundsen
Depending on how precise you want it to be, you could get a similar effect by doing a per-letter cut into the cylinder, then adding another cylinder on the inside to tidy up the cuts. This would have parallel cuts rather than radial cuts, and curves wouldn't quite match fully-mapped text:

====

rotate([0,0,-$t * 360]){
  difference(){
   cylinder(r=60, h=100, $fn=100, center=true);
     for(ltl = [0, 1]){
       lArr = ["ENGRAVED", "TEXT"][ltl];
       cCirc = 2 * PI * 60;
      for(lp = [0:(len(lArr)-1)]){
        rotate((lp*16)/cCirc * 360+(ltl * 28)) translate([60,0,-ltl*20]) rotate([90,0,90])
            linear_extrude(height=20, center=true){
              text(lArr[lp], size=16, font = "Linux Biolinum");
        }
      }
    }
  }
  color("green") cylinder(r=56, h=98, $fn=200, center=true);
}

====

Rendered image of 'ENGRAVED TEXT', engraved into a cylinder with parallel cuts per letter

Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

acwest
In reply to this post by acwest
I found my problem, and cleaned it up a bit. I redid the math on the bend module, it is now much more accurate


On Wed, Apr 14, 2021 at 6:02 PM A. Craig West <[hidden email]> wrote:
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 <[hidden email]> 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 <[hidden email]> 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

bend.scad (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Engrave text in a curved surface?

JordanBrown
In reply to this post by amundsen
The real answer to this problem is to add a function that returns the points for a particular piece of text as an array of arrays of points.  That should be straightforward.  I'll try it after I get my current text metrics work integrated.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]