discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Need help where i need to conditionall make a string to print

GH
gene heskett
Tue, Nov 7, 2023 6:40 PM

Greetings folks;

I have a case where I need to print a vars value in plastic, but it
currently is a fixed by src edit value, global in scope because its use
many times in other modules. IOW, if the value of sz in this call

to ver_txt is undef, make it the global value, if its not undef, use
the passed value.

And just to prettify the plastic, is there a way to stop str from
throwing away the .0 of a var its passed?  its messing with center=true
making the integer figure do a Russian step dance.

This module is where I ned to do that.

module ver_txt(s,t,sz)
{

color("Black")translate([-10,0,0])linear_extrude(height=t)text(ver,font
= "Utopia:style=Bold",size=s,halign="center" );

color("Black")translate([22,0,0])linear_extrude(height=t)text(tdia,font="Utopia:style=Bold",size=s,halign="center");
}; //places poor text on mating faces of nuts to indicate tooth version
and size of nut

I am successfully passing in sz, and if undef it still works right now.
Should I if(sz==undef convert sz else convert the global var? Never done
this before.

Hat in hand, take care & stay well all.

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
Greetings folks; I have a case where I need to print a vars value in plastic, but it currently is a fixed by src edit value, global in scope because its use many times in other modules. IOW, if the value of sz in this call to ver_txt is undef, make it the global value, if its not undef, use the passed value. And just to prettify the plastic, is there a way to stop str from throwing away the .0 of a var its passed? its messing with center=true making the integer figure do a Russian step dance. This module is where I ned to do that. module ver_txt(s,t,sz) { color("Black")translate([-10,0,0])linear_extrude(height=t)text(ver,font = "Utopia:style=Bold",size=s,halign="center" ); color("Black")translate([22,0,0])linear_extrude(height=t)text(tdia,font="Utopia:style=Bold",size=s,halign="center"); }; //places poor text on mating faces of nuts to indicate tooth version and size of nut I am successfully passing in sz, and if undef it still works right now. Should I if(sz==undef convert sz else convert the global var? Never done this before. Hat in hand, take care & stay well all. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis
GH
gene heskett
Tue, Nov 7, 2023 6:52 PM

On 11/7/23 13:40, gene heskett via Discuss wrote:

Greetings folks;

I have a case where I need to print a vars value in plastic, but it
currently is a fixed by src edit value, global in scope because its use
many times in other modules. IOW, if the value of sz in this call

 to ver_txt is undef, make it the global value, if its not undef, use
the passed value.

And just to prettify the plastic, is there a way to stop str from
throwing away the .0 of a var its passed?  its messing with center=true
making the integer figure do a Russian step dance.

This module is where I ned to do that.

module ver_txt(s,t,sz)
{

color("Black")translate([-10,0,0])linear_extrude(height=t)text(ver,font
= "Utopia:style=Bold",size=s,halign="center" );

color("Black")translate([22,0,0])linear_extrude(height=t)text(tdia,font="Utopia:style=Bold",size=s,halign="center");
}; //places poor text on mating faces of nuts to indicate tooth version
and size of nut

I am successfully passing in sz, and if undef it still works right now.
Should I if(sz==undef convert sz else convert the global var? Never done
this before.

Hat in hand, take care & stay well all.

nvrmnd it was easier than I thought to override the global.

Cheers, Gene Heskett.

Cheers, Gene Heskett.

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
On 11/7/23 13:40, gene heskett via Discuss wrote: > Greetings folks; > > I have a case where I need to print a vars value in plastic, but it > currently is a fixed by src edit value, global in scope because its use > many times in other modules. IOW, if the value of sz in this call > >  to ver_txt is undef, make it the global value, if its not undef, use > the passed value. > > And just to prettify the plastic, is there a way to stop str from > throwing away the .0 of a var its passed?  its messing with center=true > making the integer figure do a Russian step dance. > > This module is where I ned to do that. > > module ver_txt(s,t,sz) > { > > color("Black")translate([-10,0,0])linear_extrude(height=t)text(ver,font > = "Utopia:style=Bold",size=s,halign="center" ); > > color("Black")translate([22,0,0])linear_extrude(height=t)text(tdia,font="Utopia:style=Bold",size=s,halign="center"); > }; //places poor text on mating faces of nuts to indicate tooth version > and size of nut > > I am successfully passing in sz, and if undef it still works right now. > Should I if(sz==undef convert sz else convert the global var? Never done > this before. > > Hat in hand, take care & stay well all. nvrmnd it was easier than I thought to override the global. > > Cheers, Gene Heskett. Cheers, Gene Heskett. -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis