add profiles.scad

This commit is contained in:
zhao
2023-01-15 20:54:50 -05:00
parent 3ef4ea5cf9
commit 742e16dca5
9 changed files with 27400 additions and 30 deletions

44
rack/profiles.scad Normal file
View File

@ -0,0 +1,44 @@
/*
case-files v2
This file contains
Example usage:
profileName = "mini";
varName = "mainRailSideMountScrewType";
profile = getProfile(profileName);
echo("val:", getConfigValue(profile, varName));
*/
_profileConfigs = [
["default", [
["maxUnitWidth", 205],
["maxUnitDepth", 205],
["screwDiff", 10],
["numRailScrews", 20],
["mainRailScrewType", "m4"],
["mainRailSideMountScrewType", "m4"],
["rackFrameScrewType", "m3"],
["baseRoundness", 5],
]],
["micro", [
["maxUnitWidth", 105],
["maxUnitDepth", 105],
["numRailScrews", 10],
["baseRoundness", 5]
]],
["mini", [
["maxUnitWidth", 205],
["maxUnitDepth", 205],
["numRailScrews", 20],
["baseRoundness", 5]
]]
];
function _getConfigValueRaw(profile, varName) = profile[search([varName], profile)[0]][1];
function _getProfileRaw(profileName) = _profileConfigs[search([profileName], _profileConfigs)[0]][1];
function _getConfigValueOrThrowError(val) = val == undef? assert(false, "blah") 0: val;
function getConfigValue(profile, varName) = _getConfigValueOrThrowError(_getConfigValueRaw(profile, varName));
function getProfile(profileName) = _getConfigValueOrThrowError(_getProfileRaw(profileName));