Difference inside from artisan()

If you are making an artisan with a shape on the outside, it'd be pretty helpful if that shape didn't intrude on the stem or underside of the key
This commit is contained in:
Bob 2020-05-07 11:55:15 -04:00
parent 9103603067
commit 1174b45788
2 changed files with 28 additions and 8 deletions

View File

@ -3352,7 +3352,7 @@ SMALLEST_POSSIBLE = 1/128;
$fs = .1; $fs = .1;
$unit = 19.05; $unit = 19.05;
// key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height // key shape including dish. used as the ouside and inside shape in hollow_key(). allows for itself to be shrunk in depth and width / height
module shape(thickness_difference, depth_difference=0){ module shape(thickness_difference, depth_difference=0){
dished(depth_difference, $inverted_dish) { dished(depth_difference, $inverted_dish) {
color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0); color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0);
@ -3505,6 +3505,14 @@ module inside() {
} }
} }
// for when you want something to only exist outside the keycap
module outside() {
difference() {
children();
shape($wall_thickness, $keytop_thickness);
}
}
// put something at the top of the key, with no adjustments for dishing // put something at the top of the key, with no adjustments for dishing
module top_placement(depth_difference=0) { module top_placement(depth_difference=0) {
top_tilt_by_height = -$top_tilt / $key_height; top_tilt_by_height = -$top_tilt / $key_height;
@ -3685,7 +3693,7 @@ module artisan(depth) {
} }
// key with hollowed inside but no stem // key with hollowed inside but no stem
module keytop() { module hollow_key() {
difference(){ difference(){
if ($rounded_key) { if ($rounded_key) {
rounded_shape(); rounded_shape();
@ -3706,16 +3714,18 @@ module key(inset = false) {
difference() { difference() {
union(){ union(){
// the shape of the key, inside and out // the shape of the key, inside and out
keytop(); hollow_key();
if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge); if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge);
// additive objects at the top of the key // additive objects at the top of the key
if(!inset) artisan(0) children(); // outside() makes them stay out of the inside. it's a bad name
if(!inset) outside() artisan(0) children();
if($outset_legends) legends(0); if($outset_legends) legends(0);
// render the clearance check if it's enabled, but don't have it intersect with anything // render the clearance check if it's enabled, but don't have it intersect with anything
if ($clearance_check) %clearance_check(); if ($clearance_check) %clearance_check();
} }
// subtractive objects at the top of the key // subtractive objects at the top of the key
// no outside() - I can't think of a use for it. will save render time
if (inset) artisan($inset_legend_depth) children(); if (inset) artisan($inset_legend_depth) children();
if(!$outset_legends) legends($inset_legend_depth); if(!$outset_legends) legends($inset_legend_depth);
// subtract the clearance check if it's enabled, letting the user see the // subtract the clearance check if it's enabled, letting the user see the

View File

@ -21,7 +21,7 @@ SMALLEST_POSSIBLE = 1/128;
$fs = .1; $fs = .1;
$unit = 19.05; $unit = 19.05;
// key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height // key shape including dish. used as the ouside and inside shape in hollow_key(). allows for itself to be shrunk in depth and width / height
module shape(thickness_difference, depth_difference=0){ module shape(thickness_difference, depth_difference=0){
dished(depth_difference, $inverted_dish) { dished(depth_difference, $inverted_dish) {
color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0); color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0);
@ -174,6 +174,14 @@ module inside() {
} }
} }
// for when you want something to only exist outside the keycap
module outside() {
difference() {
children();
shape($wall_thickness, $keytop_thickness);
}
}
// put something at the top of the key, with no adjustments for dishing // put something at the top of the key, with no adjustments for dishing
module top_placement(depth_difference=0) { module top_placement(depth_difference=0) {
top_tilt_by_height = -$top_tilt / $key_height; top_tilt_by_height = -$top_tilt / $key_height;
@ -354,7 +362,7 @@ module artisan(depth) {
} }
// key with hollowed inside but no stem // key with hollowed inside but no stem
module keytop() { module hollow_key() {
difference(){ difference(){
if ($rounded_key) { if ($rounded_key) {
rounded_shape(); rounded_shape();
@ -375,16 +383,18 @@ module key(inset = false) {
difference() { difference() {
union(){ union(){
// the shape of the key, inside and out // the shape of the key, inside and out
keytop(); hollow_key();
if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge); if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge);
// additive objects at the top of the key // additive objects at the top of the key
if(!inset) artisan(0) children(); // outside() makes them stay out of the inside. it's a bad name
if(!inset) outside() artisan(0) children();
if($outset_legends) legends(0); if($outset_legends) legends(0);
// render the clearance check if it's enabled, but don't have it intersect with anything // render the clearance check if it's enabled, but don't have it intersect with anything
if ($clearance_check) %clearance_check(); if ($clearance_check) %clearance_check();
} }
// subtractive objects at the top of the key // subtractive objects at the top of the key
// no outside() - I can't think of a use for it. will save render time
if (inset) artisan($inset_legend_depth) children(); if (inset) artisan($inset_legend_depth) children();
if(!$outset_legends) legends($inset_legend_depth); if(!$outset_legends) legends($inset_legend_depth);
// subtract the clearance check if it's enabled, letting the user see the // subtract the clearance check if it's enabled, letting the user see the