I have the following code working correctly:
//Size of larger tube?
tube_1 = 33.7; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55, 34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//Size of smaller tube?
tube_2 = 13.8; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55, 34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//How long do you want the taper to be?
taper_length = 25;
//Diameter of the hole through the center? Use "0" for no hole. Must be
smaller than diameter of the small tube.
hole = 12.4;
wall_1 = .53;
wall_2 = .33;
difference(){
union(){
cylinder(h=taper_length, r1=tube_1/2, r2=tube_2/2, center=false, $fn=100);
translate([0,0,taper_length]) cylinder(h=12.7,r=tube_2/2-wall_2,
center=false, $fn=100);
translate([0,0,-12.7]) cylinder(h=12.7,r=tube_1/2-wall_1, center=false,
$fn=100);
}
translate([0,0,-12.7]) cylinder(h=taper_length+25.4, r=hole/2, center=false,
$fn=100);
}
I would like the "wall_1" and "wall_2" values to be dependent upon the
selections for "tube_1" and "tube_2". I have been trying to use an if/else
statement but I haven't been able to get it to work.
I am trying to do something like "If tube_1=13.8, 18.7, or 24.8; then
wall_1=0.33, else wall_1=0.53".
Any ideas?
--
View this message in context: http://forum.openscad.org/Need-some-help-with-if-else-statement-tp14080.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
wall_1 = tube_1 == 13.8 || tube_1 == 18.7 || tube_1 == 24.8 ? 0.33 : 0.53;
On 7 October 2015 at 17:09, entomophile entomophile@gmail.com wrote:
I have the following code working correctly:
//Size of larger tube?
tube_1 = 33.7; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55,
34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//Size of smaller tube?
tube_2 = 13.8; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55,
34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//How long do you want the taper to be?
taper_length = 25;
//Diameter of the hole through the center? Use "0" for no hole. Must be
smaller than diameter of the small tube.
hole = 12.4;
wall_1 = .53;
wall_2 = .33;
difference(){
union(){
cylinder(h=taper_length, r1=tube_1/2, r2=tube_2/2, center=false, $fn=100);
translate([0,0,taper_length]) cylinder(h=12.7,r=tube_2/2-wall_2,
center=false, $fn=100);
translate([0,0,-12.7]) cylinder(h=12.7,r=tube_1/2-wall_1, center=false,
$fn=100);
}
translate([0,0,-12.7]) cylinder(h=taper_length+25.4, r=hole/2,
center=false,
$fn=100);
}
I would like the "wall_1" and "wall_2" values to be dependent upon the
selections for "tube_1" and "tube_2". I have been trying to use an if/else
statement but I haven't been able to get it to work.
I am trying to do something like "If tube_1=13.8, 18.7, or 24.8; then
wall_1=0.33, else wall_1=0.53".
Any ideas?
--
View this message in context:
http://forum.openscad.org/Need-some-help-with-if-else-statement-tp14080.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
That works! Wow, so much going on in that one line of code. Thanks so much
for the help.
--
View this message in context: http://forum.openscad.org/Need-some-help-with-if-else-statement-tp14080p14082.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
wall_1 = tube_1 < 25 ? 0.33 : 0.53;
:-)
From: Discuss [discuss-bounces@lists.openscad.org] on behalf of nop head [nop.head@gmail.com]
Sent: 07 October 2015 19:26
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Need some help with "if-else" statement.
wall_1 = tube_1 == 13.8 || tube_1 == 18.7 || tube_1 == 24.8 ? 0.33 : 0.53;
On 7 October 2015 at 17:09, entomophile <entomophile@gmail.commailto:entomophile@gmail.com> wrote:
I have the following code working correctly:
//Size of larger tube?
tube_1 = 33.7; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55, 34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//Size of smaller tube?
tube_2 = 13.8; //[13.8:BT-5, 18.7:BT-20, 24.8:BT-50, 33.7:BT-55, 34.2:BT-56,
41.6:BT-60, 56.3:BT-70, 66.04:BT-80, 100:BT-101]
//How long do you want the taper to be?
taper_length = 25;
//Diameter of the hole through the center? Use "0" for no hole. Must be
smaller than diameter of the small tube.
hole = 12.4;
wall_1 = .53;
wall_2 = .33;
difference(){
union(){
cylinder(h=taper_length, r1=tube_1/2, r2=tube_2/2, center=false, $fn=100);
translate([0,0,taper_length]) cylinder(h=12.7,r=tube_2/2-wall_2,
center=false, $fn=100);
translate([0,0,-12.7]) cylinder(h=12.7,r=tube_1/2-wall_1, center=false,
$fn=100);
}
translate([0,0,-12.7]) cylinder(h=taper_length+25.4, r=hole/2, center=false,
$fn=100);
}
I would like the "wall_1" and "wall_2" values to be dependent upon the
selections for "tube_1" and "tube_2". I have been trying to use an if/else
statement but I haven't been able to get it to work.
I am trying to do something like "If tube_1=13.8, 18.7, or 24.8; then
wall_1=0.33, else wall_1=0.53".
Any ideas?
--
View this message in context: http://forum.openscad.org/Need-some-help-with-if-else-statement-tp14080.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.orgmailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Another good solution, thank you. I wasn't aware of the conditional
operator. Very useful.
--
View this message in context: http://forum.openscad.org/Need-some-help-with-if-else-statement-tp14080p14084.html
Sent from the OpenSCAD mailing list archive at Nabble.com.