Closed edasque closed 7 years ago
Hey there!
For a brief example of how to use the new script you can check out the description on thingiverse: https://www.thingiverse.com/thing:468651 specifically this guy:
No more profile arrays! keys are generated by stringing together nestable functions, which are much, much more readable.
translate_u(0, 1) 2u() dcs_row(1) alps() key();
would generate an alps-compatible DCS row 1 keycap that's 2 units long, and translated 1 unit in the y direction. The ordering is important;key()
has to be last and there are some other gotchas, so generally stick with[translate] [length] [height] [type] [stem]
. Iterations can be applied to these chains to quickly generate key layouts. The new entrypoint for this iskeys.scad
;key.scad
is now meant as more of a construction library for super detailed stuff.
but I should definitely include a readme in the github repo once all is said and done. Basically, everything in keys.scad is just manipulating special variables that are the parameters to key.scad, changing the shape of the key. Since special variables are scoped to the module they are redefined in, all the functions in keys.scad reference the children()
function and need to be nested. translate_u(0, 1) 2u() dcs_row(1) alps() key();
is just shorthand for
translate_u(0, 1){
2u(){
dcs_row(1){
alps(){
key();
}
}
}
}
where every function except for key()
is just modifying the parameters that key()
uses to generate the keycap. I can write a reference table for the modifier functions available but for now your best bet is reading keys.scad.
As to why your keycaps are rendering solid, I believe you aren't specifying a stem profile. The current stem profiles are cherry, alps, and rounded cherry, which can be accessed via cherry()
, alps()
, and rounded_cherry()
respectively. dcs_row(1) cherry() key()
should get you something similar to your picture, but with a square cherry stem. I should probaby default to cherry, that's what most people will be using the library for.
Openscad does support unicode text objects but they must be referenced by code, not pasted into the document. The wikipedia page doesn't have a hyperlink so I'll just paste in the snippet that mentions it:
seen here, somewhere.
Let me know if that answers your questions and if there's anything else you need!
All right, so I think I get it. I was modifying /key/key.scad (I am guessing /key/key_v2.zip is not ready for prime time) but really I should be changing keys.scad and specifically these last few lines:
for (row=[1:4]) {
stem_rotation = 25;
text="e";
for (column = [1:1]) {
translate_u(column - 1, 4 - row) dcs_row(row) cherry_key();
}
}
This works and the long bars don't render so we're good. Where should I place the changes to stem_rotation & text ? They don't seem to work there. I am just learning OpenScad so it's probably obvious. I am guessing it's not about changing the variable but calling the right function in the chain?
I also get solid keycaps with no visible stems. Was there something specific you did to get it to work?
Even rsheldiii's example of dcs_row(1) cherry() key();
gives a solid keycap
@shendriksza it doesn't for me. Are you editing keys.scad ? Do you see these big bars, what does it look like in render mode? What version, platform for OpenScad?
Actually, let me correct that, you are right @shendriksza with the most recent two commits, I don't have stems anymore.
dcs_row(1) cherry() key();
at the bottom of keys.scad renders without caps
@rsheldiii any idea? I don't see stems or those long rectangular cuboid
on 6af3e25 everything is working just fine for me:
on both mac and pc. I would double check that you are up to date on master, I would also close and restart openscad, as sometimes it doesn't take changes from included files into effect. I think the most likely culprit is switching from numbers to strings for the $stem_profile variable. if the problem still persists, can you run
dcs_row(1) cherry() {
echo($stem_profile);
key();
}
and tell me what pops out in the console? it should be "cherry"
as to your previos question @edasque you need to modify the special variables instead of the local variables to effect changes to the keycap, so if you modify your script to say
for (row=[1:4]) {
$stem_rotation = 25;
$text="e";
for (column = [1:1]) {
translate_u(column - 1, 4 - row) dcs_row(row) cherry() key();
}
}
it should work. there is the legend()
function which allows you to specify text (and inset), but the rotated()
function only does 90 degrees right now, I can patch it to allow for a rotation variable. what are you doing with 25 degree rotated stems though?
I’ll try that and let you know.
The rotate 25 was just so I could be sure it was working, it’s easier to notice than 90. 90 is what I’ll want though.
Yeah, so with OpenSCAD version 2015.03-3 on MacOS High Sierra:
dcs_row(1) cherry() key();
I still get a filled in keycap (
with
dcs_row(1) cherry() {
echo($stem_profile);
key();
}
I get in the console:
Compiling design (CSG Tree generation)...
ECHO: "cherry"
Compiling design (CSG Products generation)...
with
for (row=[1:4]) {
$stem_rotation = 25;
for (column = [1:1]) {
translate_u(column - 1, 4 - row) dcs_row(row) legend("Y") cherry() key();
}
}
I did get 4 keycaps but still without a stem.
Note that I don't see those long rectangular columns that I saw in previous versions. When those were there, I could see the stems.
(I restarted OpenScad, closed the files, removed /Users/ed/Library/Caches/org.openscad.OpenSCAD)
ah, I'm on 2017.01:20 and 2017.02.08 on windows and mac. downgrading reproduces the issue, I'll see if I can fix it, but in the meantime upgrading to the development snapshot should fix the issue for both of you as well
master should be fixed, I was doing something funky with the special variables you probably shouldn't be allowed to do. I'm going to be merging in tweaks I've made to the stem and support momentarily, if you want just the fix you can stick to 79d278b8a32af2679774efc6be8c0ed726db408a
Sorry for only getting back now, timezones and stuff. Yes I was also using the 2015.03-2 OpenSCAD build for Windows, I didn't even realise there was a development build until you mentioned it. I'm definitely switching over to that one anyway, although most users will probably be using the old stable one so I still think the fix is necessary. But thanks for everyone's effort!
Same here, switched to that and the dev build, no issues now. Thank you for your help! We're both makers & developers from Boston.
(As you gear up for 2.0, can you give a short overview on how to use this to generate a usable STL for a keycap in OpenScad? What basic parameters exist and how you can change them?)
The main thing I can't seem to achieve is actually get the Cherry MX stem (is that the right word for it?)
Another question is whether this supports unicode characters for the keycaps for the text variable?
My keycaps all look filled in: