mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-03-09 02:39:47 +00:00
Merge pull request #308 from revarbat/revarbat_dev
Fix for cuboid issue #307
This commit is contained in:
commit
b3f292200a
4 changed files with 16 additions and 17 deletions
17
shapes.scad
17
shapes.scad
|
@ -78,14 +78,15 @@ module cuboid(
|
||||||
cnt = sum(e);
|
cnt = sum(e);
|
||||||
r = first_defined([chamfer, rounding, 0]);
|
r = first_defined([chamfer, rounding, 0]);
|
||||||
c = [min(r,size.x/2), min(r,size.y/2), min(r,size.z/2)];
|
c = [min(r,size.x/2), min(r,size.y/2), min(r,size.z/2)];
|
||||||
|
c2 = vmul(corner,c/2);
|
||||||
$fn = is_finite(chamfer)? 4 : segs(r);
|
$fn = is_finite(chamfer)? 4 : segs(r);
|
||||||
translate(vmul(corner,size/2-c)) {
|
translate(vmul(corner, size/2-c)) {
|
||||||
if (cnt == 0) {
|
if (cnt == 0) {
|
||||||
cube(c*2, center=true);
|
translate(c2) cube(c, center=true);
|
||||||
} else if (cnt == 1) {
|
} else if (cnt == 1) {
|
||||||
if (e.x) xcyl(l=c.x*2, r=r);
|
if (e.x) right(c2.x) xcyl(l=c.x, r=r);
|
||||||
if (e.y) ycyl(l=c.y*2, r=r);
|
if (e.y) back (c2.y) ycyl(l=c.y, r=r);
|
||||||
if (e.z) zcyl(l=c.z*2, r=r);
|
if (e.z) up (c2.z) zcyl(l=c.z, r=r);
|
||||||
} else if (cnt == 2) {
|
} else if (cnt == 2) {
|
||||||
if (!e.x) {
|
if (!e.x) {
|
||||||
intersection() {
|
intersection() {
|
||||||
|
@ -152,9 +153,9 @@ module cuboid(
|
||||||
} else {
|
} else {
|
||||||
isize = [for (v = size) max(0.001, v-2*chamfer)];
|
isize = [for (v = size) max(0.001, v-2*chamfer)];
|
||||||
hull() {
|
hull() {
|
||||||
cube([size.x, isize.y, isize.z], center=true);
|
cube([ size.x, isize.y, isize.z], center=true);
|
||||||
cube([isize.x, size.y, isize.z], center=true);
|
cube([isize.x, size.y, isize.z], center=true);
|
||||||
cube([isize.x, isize.y, size.z], center=true);
|
cube([isize.x, isize.y, size.z], center=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (chamfer<0) {
|
} else if (chamfer<0) {
|
||||||
|
|
12
strings.scad
12
strings.scad
|
@ -626,7 +626,6 @@ function is_letter(s) =
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// fmt = The formatting string, with placeholders to format the values into.
|
// fmt = The formatting string, with placeholders to format the values into.
|
||||||
// vals = The list of values to format.
|
// vals = The list of values to format.
|
||||||
// use_nbsp = Pad fields with HTML entity ` ` instead of spaces.
|
|
||||||
// Example(NORENDER):
|
// Example(NORENDER):
|
||||||
// str_format("The value of {} is {:.14f}.", ["pi", PI]); // Returns: "The value of pi is 3.14159265358979."
|
// str_format("The value of {} is {:.14f}.", ["pi", PI]); // Returns: "The value of pi is 3.14159265358979."
|
||||||
// str_format("The value {1:f} is known as {0}.", ["pi", PI]); // Returns: "The value 3.141593 is known as pi."
|
// str_format("The value {1:f} is known as {0}.", ["pi", PI]); // Returns: "The value 3.141593 is known as pi."
|
||||||
|
@ -634,7 +633,7 @@ function is_letter(s) =
|
||||||
// str_format("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // Returns: "foo 12000true"
|
// str_format("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // Returns: "foo 12000true"
|
||||||
// str_format("{:-10s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostamus27.440"
|
// str_format("{:-10s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostamus27.440"
|
||||||
// str_format("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostam 27.440"
|
// str_format("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // Returns: "plecostam 27.440"
|
||||||
function str_format(fmt, vals, use_nbsp=false) =
|
function str_format(fmt, vals) =
|
||||||
let(
|
let(
|
||||||
parts = str_split(fmt,"{")
|
parts = str_split(fmt,"{")
|
||||||
) str_join([
|
) str_join([
|
||||||
|
@ -676,7 +675,7 @@ function str_format(fmt, vals, use_nbsp=false) =
|
||||||
typ=="G"? upcase(fmt_float(val,default(prec,6))) :
|
typ=="G"? upcase(fmt_float(val,default(prec,6))) :
|
||||||
assert(false,str("Unknown format type: ",typ)),
|
assert(false,str("Unknown format type: ",typ)),
|
||||||
padlen = max(0,wid-len(unpad)),
|
padlen = max(0,wid-len(unpad)),
|
||||||
padfill = str_join([for (i=[0:1:padlen-1]) zero? "0" : use_nbsp? " " : " "]),
|
padfill = str_join([for (i=[0:1:padlen-1]) zero? "0" : " "]),
|
||||||
out = left? str(unpad, padfill) : str(padfill, unpad)
|
out = left? str(unpad, padfill) : str(padfill, unpad)
|
||||||
)
|
)
|
||||||
out, raw
|
out, raw
|
||||||
|
@ -692,7 +691,6 @@ function str_format(fmt, vals, use_nbsp=false) =
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// fmt = The formatting string, with placeholders to format the values into.
|
// fmt = The formatting string, with placeholders to format the values into.
|
||||||
// vals = The list of values to format.
|
// vals = The list of values to format.
|
||||||
// use_nbsp = Pad fields with HTML entity ` ` instead of spaces.
|
|
||||||
// Example(NORENDER):
|
// Example(NORENDER):
|
||||||
// echofmt("The value of {} is {:.14f}.", ["pi", PI]); // ECHO: "The value of pi is 3.14159265358979."
|
// echofmt("The value of {} is {:.14f}.", ["pi", PI]); // ECHO: "The value of pi is 3.14159265358979."
|
||||||
// echofmt("The value {1:f} is known as {0}.", ["pi", PI]); // ECHO: "The value 3.141593 is known as pi."
|
// echofmt("The value {1:f} is known as {0}.", ["pi", PI]); // ECHO: "The value 3.141593 is known as pi."
|
||||||
|
@ -700,10 +698,10 @@ function str_format(fmt, vals, use_nbsp=false) =
|
||||||
// echofmt("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // ECHO: "foo 12000true"
|
// echofmt("{:-5s}{:i}{:b}", ["foo", 12e3, 5]); // ECHO: "foo 12000true"
|
||||||
// echofmt("{:-10s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostamus27.440"
|
// echofmt("{:-10s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostamus27.440"
|
||||||
// echofmt("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostam 27.440"
|
// echofmt("{:-10.9s}{:.3f}", ["plecostamus",27.43982]); // ECHO: "plecostam 27.440"
|
||||||
function echofmt(fmt, vals, use_nbsp=false) = echo(str_format(fmt,vals,use_nbsp));
|
function echofmt(fmt, vals) = echo(str_format(fmt,vals));
|
||||||
module echofmt(fmt, vals, use_nbsp=false) {
|
module echofmt(fmt, vals) {
|
||||||
no_children($children);
|
no_children($children);
|
||||||
echo(str_format(fmt,vals,use_nbsp));
|
echo(str_format(fmt,vals));
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -96,7 +96,7 @@ function struct_keys(struct) =
|
||||||
// struct = input structure
|
// struct = input structure
|
||||||
// name = optional structure name to list at the top of the output. Default: ""
|
// name = optional structure name to list at the top of the output. Default: ""
|
||||||
function struct_echo(struct,name="") =
|
function struct_echo(struct,name="") =
|
||||||
let( keylist = [for(entry=struct) str(" ",entry[0],": ",entry[1],"\n")])
|
let( keylist = [for(entry=struct) str(" ",entry[0],": ",entry[1],"\n")])
|
||||||
echo(str("\nStructure ",name,"\n",str_join(keylist)))
|
echo(str("\nStructure ",name,"\n",str_join(keylist)))
|
||||||
undef;
|
undef;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,459];
|
BOSL_VERSION = [2,0,461];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue