how to assign letters/numbers October 15, 2015 11:14AM |
Registered: 9 years ago Posts: 780 |

I have only seen the use of lettering when the actual letter/numbers are defined.

What I would like to do, if possible, is to have a routine that will print a letter/number that has been calculated.

This is what I have at the moment ( with a lot of help)

Size=3.0;

NumHoles = 8; // Number of holes

Gap = 2.5; // Gap between holes

First=Size; // Diamater of first hole

Increase=0.05; // Radius size increase per hole

Margin=Size+1; // Border around block

base=3;

HolesX=2*(NumHoles*First/2)+(NumHoles-1)*(Gap+NumHoles*Increase); // Total X length of holes

HolesY=2*(First/2+(NumHoles-1)*Increase); // Diameter of largest hole

font = "Liberation Sans";

letter_size = Size-1;

letter_height = 5;

module Holes(){

for(i=[0:NumHoles-1])

{

translate([i*(Gap+First+i*Increase),0,-0.5])

cylinder(r=First/2+i*Increase, h=base+1, $fn=20);

}}

module letter(l) {

linear_extrude(height = letter_height) {

text(l, size = letter_size, font = font, halign = "center", valign = "center", $fn = 100);

}}

difference()

{

translate([-Margin-First/2,-Margin-HolesY/2,0])

cube ([2*Margin+HolesX,2*Margin+HolesY,base]);

Holes();

translate([0,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("3.0");

translate([(HolesX-HolesY+0.5)/2,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("0.05 mm steps");

translate([HolesX-HolesY+0.5,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("3.35");

}

I would like the letters/numbers to be the result of a calculation, i.e. First, Increase, HolesY

Is this possible?

Thanks for any help

Paul

appjaws - Core XYUV Duet Ethernet Duex5

firmware 3.1.1 Web Interface 3.1.1

Ormerod 1-converted to laser engraver, Duet wifi

OpenSCAD version 2020.07

slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1

What I would like to do, if possible, is to have a routine that will print a letter/number that has been calculated.

This is what I have at the moment ( with a lot of help)

Size=3.0;

NumHoles = 8; // Number of holes

Gap = 2.5; // Gap between holes

First=Size; // Diamater of first hole

Increase=0.05; // Radius size increase per hole

Margin=Size+1; // Border around block

base=3;

HolesX=2*(NumHoles*First/2)+(NumHoles-1)*(Gap+NumHoles*Increase); // Total X length of holes

HolesY=2*(First/2+(NumHoles-1)*Increase); // Diameter of largest hole

font = "Liberation Sans";

letter_size = Size-1;

letter_height = 5;

module Holes(){

for(i=[0:NumHoles-1])

{

translate([i*(Gap+First+i*Increase),0,-0.5])

cylinder(r=First/2+i*Increase, h=base+1, $fn=20);

}}

module letter(l) {

linear_extrude(height = letter_height) {

text(l, size = letter_size, font = font, halign = "center", valign = "center", $fn = 100);

}}

difference()

{

translate([-Margin-First/2,-Margin-HolesY/2,0])

cube ([2*Margin+HolesX,2*Margin+HolesY,base]);

Holes();

translate([0,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("3.0");

translate([(HolesX-HolesY+0.5)/2,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("0.05 mm steps");

translate([HolesX-HolesY+0.5,-Margin/2-HolesY/2, base-2]) rotate([0, 0, 0]) letter("3.35");

}

I would like the letters/numbers to be the result of a calculation, i.e. First, Increase, HolesY

Is this possible?

Thanks for any help

Paul

appjaws - Core XYUV Duet Ethernet Duex5

firmware 3.1.1 Web Interface 3.1.1

Ormerod 1-converted to laser engraver, Duet wifi

OpenSCAD version 2020.07

slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1

Re: how to assign letters/numbers October 15, 2015 02:50PM |
Registered: 8 years ago Posts: 590 |

Re: how to assign letters/numbers October 16, 2015 02:26AM |
Registered: 9 years ago Posts: 780 |

Quoteenif

You could use OpenScad'sstr()function to convert numbers to strings and concatenate strings, see here. E.g.letter(str(Increment," mm step"));

Brilliant, thank you works great.

Is there a way to force 1 decimal place, at the moment I have Size=3.0, First=Size but if I use letter(str(First,".0")); I get just 3 not 3.0

edit: sorry the line should be:-

Is there a way to force 1 decimal place, at the moment I have Size=3.0, First=Size but if I use letter(str(First)); I get just 3 not 3.0 so I am using --- letter(str(First,".0")) which solves the problem but only if the First is a whole number.

Edited 1 time(s). Last edit at 10/16/2015 11:10AM by appjaws1.

appjaws - Core XYUV Duet Ethernet Duex5

firmware 3.1.1 Web Interface 3.1.1

Ormerod 1-converted to laser engraver, Duet wifi

OpenSCAD version 2020.07

slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1

Re: how to assign letters/numbers October 16, 2015 08:17AM |
Registered: 8 years ago Posts: 590 |

Re: how to assign letters/numbers October 16, 2015 11:19AM |
Registered: 9 years ago Posts: 780 |

Quoteenif

str(floor(First),".",floor(10*(First-floor(First))+0.5));

Your a star, works great

translate([0,-Margin/2-HolesY/2, 1]) letter(str(floor(First),".",floor(10*(First-floor(First))+0.5)));

Thank you enif

appjaws - Core XYUV Duet Ethernet Duex5

firmware 3.1.1 Web Interface 3.1.1

Ormerod 1-converted to laser engraver, Duet wifi

OpenSCAD version 2020.07

slic3r-1.3.0, Simplify3D 4.1.2, Cura-4.4.1

Sorry, only registered users may post in this forum.