FeatureScript 3095; import(path : "onshape/std/geometry.fs", version : "3095.0"); // ===================================================================================== // Glovebox glove // Builds a five-fingered glovebox glove from a selected port opening profile. // // Layout (all derived from the inputs): // - The cuff starts on the selected planar profile (port ring / opening) and runs along // the profile normal. // - The sleeve tapers from the cuff (equivalent radius of the profile) to the wrist. // It runs straight for a short cuff length, then bends toward "down" by the droop // angle (0 deg = sticking straight out of the port, 90 deg = hanging straight down), // then runs straight to the wrist. // - The hand (palm loft + four fingers + two-segment thumb) is built in a frame at the // wrist: axis = sleeve end tangent, palm facing down (rotated with the droop) and // optionally rolled about the arm axis. // - Glove length is measured along the glove centreline from the port profile to the // tip of the middle finger. // ===================================================================================== export enum GloveHand { annotation { "Name" : "Right hand" } RIGHT, annotation { "Name" : "Left hand" } LEFT } const GLOVE_LENGTH_BOUNDS = { (meter) : [0.15, 0.8128, 5], (millimeter) : 812.8, (inch) : 32 } as LengthBoundSpec; const HAND_LENGTH_BOUNDS = { (meter) : [0.05, 0.2, 1], (millimeter) : 200, (inch) : 8 } as LengthBoundSpec; const WRIST_DIA_BOUNDS = { (meter) : [0.02, 0.09, 1], (millimeter) : 90, (inch) : 3.5 } as LengthBoundSpec; const WALL_BOUNDS = { (meter) : [1e-4, 0.0008, 0.02], (millimeter) : 0.8, (inch) : 0.03 } as LengthBoundSpec; const DROOP_BOUNDS = { (degree) : [0, 30, 120] } as AngleBoundSpec; const ROLL_BOUNDS = { (degree) : [-180, 0, 180] } as AngleBoundSpec; annotation { "Feature Type Name" : "Glovebox glove", "Feature Type Description" : "Five-fingered glovebox glove from a port opening profile, with length and droop angle." } export const gloveboxGlove = defineFeature(function(context is Context, id is Id, definition is map) precondition { annotation { "Name" : "Port opening profile", "Filter" : EntityType.FACE && GeometryType.PLANE, "MaxNumberOfPicks" : 1, "Description" : "Planar face or sketch region that forms the glove cuff opening (e.g. the glove port circle)." } definition.profile is Query; annotation { "Name" : "Flip direction", "UIHint" : UIHint.OPPOSITE_DIRECTION } definition.flip is boolean; annotation { "Name" : "Glove length (cuff to fingertip)" } isLength(definition.length, GLOVE_LENGTH_BOUNDS); annotation { "Name" : "Droop angle", "Description" : "0 deg = glove sticks straight out of the port, 90 deg = glove hangs straight down." } isAngle(definition.droop, DROOP_BOUNDS); annotation { "Name" : "Down direction (default world -Z)", "Filter" : QueryFilterCompound.ALLOWS_DIRECTION, "MaxNumberOfPicks" : 1 } definition.downRef is Query; annotation { "Name" : "Flip down direction", "UIHint" : UIHint.OPPOSITE_DIRECTION } definition.flipDown is boolean; annotation { "Name" : "Hand", "UIHint" : UIHint.SHOW_LABEL } definition.hand is GloveHand; annotation { "Name" : "Hand length (wrist to fingertip)" } isLength(definition.handLength, HAND_LENGTH_BOUNDS); annotation { "Name" : "Wrist diameter" } isLength(definition.wristDia, WRIST_DIA_BOUNDS); annotation { "Name" : "Hand roll about arm axis", "Description" : "0 deg = palm faces down." } isAngle(definition.roll, ROLL_BOUNDS); annotation { "Name" : "Hollow (wall thickness)", "Default" : false } definition.hollow is boolean; if (definition.hollow) { annotation { "Name" : "Wall thickness" } isLength(definition.wall, WALL_BOUNDS); } } { verifyNonemptyQuery(context, definition, "profile", "Select the port opening profile (a planar face or sketch region)."); const remainingTransform = getRemainderPatternTransform(context, { "references" : definition.profile }); // ---------------------------------------------------------------- port frame const pl = evPlane(context, { "face" : definition.profile }); const O = evApproximateCentroid(context, { "entities" : definition.profile }); const r0 = sqrt(evArea(context, { "entities" : definition.profile }) / PI); // equivalent cuff radius var n = pl.normal; if (definition.flip) n = -n; var g = vector(0, 0, -1); if (!isQueryEmpty(context, definition.downRef)) g = extractDirection(context, definition.downRef); if (definition.flipDown) g = -g; var d = g - dot(g, n) * n; // "down" in the plane of the port if (norm(d) < 1e-6) d = perpendicularVector(n); // port faces straight up/down: any side d = normalize(d); // ---------------------------------------------------------------- sizes const L = definition.length; const H = definition.handLength; const rw = definition.wristDia / 2; const Ls = L - H; // sleeve centreline length (cuff to wrist) if (Ls < max(0.2 * L, r0)) throw regenError("Glove length is too short for the hand length. Increase the glove length or reduce the hand length.", ["length", "handLength"]); if (rw >= r0) throw regenError("Wrist diameter must be smaller than the port opening.", ["wristDia"]); const th = definition.droop / radian; // droop angle as a plain number (radians) const c = 0.12 * Ls; // straight cuff section var R = max(2 * r0, 0.25 * Ls); // bend radius of the droop if (th > 1e-6) R = min(R, (0.75 * Ls - c) / th); const spine = { "O" : O, "n" : n, "d" : d, "c" : c, "R" : R, "th" : th, "Ls" : Ls }; // ---------------------------------------------------------------- sleeve sections var sections = [definition.profile]; const N = 8; for (var k = 1; k <= N; k += 1) { const s = (k == 1) ? c : c + (Ls - c) * (k - 1) / (N - 1); const f = s / Ls; const r = rw + (r0 - rw) * (1 - f) ^ 1.15; const sp = spineAt(spine, s); const skId = id + ("sleeve" ~ k); const sk = newSketchOnPlane(context, skId, { "sketchPlane" : plane(sp.point, sp.tangent, perpendicularVector(sp.tangent)) }); skCircle(sk, "c", { "center" : vector(0, 0) * meter, "radius" : r }); skSolve(sk); sections = append(sections, qSketchRegion(skId)); } // ---------------------------------------------------------------- hand frame at the wrist const W = spineAt(spine, Ls); const a = W.tangent; // along the hand, toward the fingers const p0 = cos(th * radian) * d - sin(th * radian) * n; // palm normal (faces down at 0 deg droop) const p = normalize(cos(definition.roll) * p0 + sin(definition.roll) * cross(a, p0)); const u = (definition.hand == GloveHand.RIGHT ? 1 : -1) * normalize(cross(a, p)); // toward the thumb const P = 0.5 * H; // wrist to knuckles const Wp = 0.52 * H; // palm width (glove, slightly inflated) const Tp = 0.2 * H; // palm thickness const palm = [[0.18 * H, 0.85 * Wp / 2, max(0.55 * Tp, 0.7 * rw)], [0.4 * H, Wp / 2, Tp / 2], [P, 0.97 * Wp / 2, 0.48 * Tp]]; for (var k = 0; k < size(palm); k += 1) { const skId = id + ("palm" ~ k); const sk = newSketchOnPlane(context, skId, { "sketchPlane" : plane(W.point + palm[k][0] * a, a, u) }); skEllipse(sk, "e", { "center" : vector(0, 0) * meter, "majorRadius" : palm[k][1], "minorRadius" : min(palm[k][2], 0.95 * palm[k][1]) }); skSolve(sk); sections = append(sections, qSketchRegion(skId)); } opLoft(context, id + "loft", { "profileSubqueries" : sections, "bodyType" : ToolBodyType.SOLID }); var sketchIds = []; for (var k = 1; k <= N; k += 1) sketchIds = append(sketchIds, qCreatedBy(id + ("sleeve" ~ k), EntityType.BODY)); for (var k = 0; k < size(palm); k += 1) sketchIds = append(sketchIds, qCreatedBy(id + ("palm" ~ k), EntityType.BODY)); opDeleteBodies(context, id + "deleteSketches", { "entities" : qUnion(sketchIds) }); // ---------------------------------------------------------------- fingers // [lateral offset in pitches toward the thumb, length factor, splay (deg, + toward thumb), base setback / H] const pitch = 0.95 * Wp / 4; const rf = 0.52 * pitch; const Fm = H - P; // middle finger length beyond the knuckles const embed = 0.1 * H; const fingers = [[1.5, 0.92, 5, 0], [0.5, 1.0, 1, 0], [-0.5, 0.94, -3, 0], [-1.5, 0.76, -8, 0.04]]; var tools = [qCreatedBy(id + "loft", EntityType.BODY)]; for (var k = 0; k < size(fingers); k += 1) { const fd = fingers[k]; const dir = normalize(cos(fd[2] * degree) * a + sin(fd[2] * degree) * u); const base = W.point + (P - embed - fd[3] * H) * a + fd[0] * pitch * u; const rt = 0.85 * rf; const tip = base + (fd[1] * Fm + embed - rt) * dir; fCone(context, id + ("finger" ~ k), { "bottomCenter" : base, "topCenter" : tip, "bottomRadius" : rf, "topRadius" : rt }); opSphere(context, id + ("fingerTip" ~ k), { "center" : tip, "radius" : rt }); tools = concatenateArrays([tools, [qCreatedBy(id + ("finger" ~ k), EntityType.BODY), qCreatedBy(id + ("fingerTip" ~ k), EntityType.BODY)]]); } // ---------------------------------------------------------------- thumb (two segments) const tBase = W.point + 0.15 * H * a + 0.3 * Wp * u + 0.1 * Tp * p; const tDir1 = normalize(a + 0.7 * u + 0.35 * p); const tJoint = tBase + 0.2 * H * tDir1; const tDir2 = normalize(a + 0.25 * u + 0.3 * p); const rtb = 1.3 * rf; const rtj = 1.0 * rf; const rtt = 0.9 * rf; const tTip = tJoint + (0.2 * H - rtt) * tDir2; fCone(context, id + "thumb1", { "bottomCenter" : tBase, "topCenter" : tJoint, "bottomRadius" : rtb, "topRadius" : rtj }); opSphere(context, id + "thumbJoint", { "center" : tJoint, "radius" : rtj }); fCone(context, id + "thumb2", { "bottomCenter" : tJoint, "topCenter" : tTip, "bottomRadius" : rtj, "topRadius" : rtt }); opSphere(context, id + "thumbTip", { "center" : tTip, "radius" : rtt }); tools = concatenateArrays([tools, [qCreatedBy(id + "thumb1", EntityType.BODY), qCreatedBy(id + "thumbJoint", EntityType.BODY), qCreatedBy(id + "thumb2", EntityType.BODY), qCreatedBy(id + "thumbTip", EntityType.BODY)]]); opBoolean(context, id + "union", { "tools" : qUnion(tools), "operationType" : BooleanOperationType.UNION }); const glove = qCreatedBy(id + "loft", EntityType.BODY); // ---------------------------------------------------------------- optional hollow if (definition.hollow) { const cuffFace = qCoincidesWithPlane(qOwnedByBody(glove, EntityType.FACE), plane(O, n)); if (isQueryEmpty(context, cuffFace)) reportFeatureWarning(context, id, "Could not find the cuff face to open the glove; left solid."); else { try { opShell(context, id + "shell", { "entities" : qUnion([cuffFace, glove]), "thickness" : definition.wall }); } catch { reportFeatureWarning(context, id, "Could not hollow the glove at this wall thickness; left solid."); } } } transformResultIfNecessary(context, id, remainingTransform); setProperty(context, { "entities" : glove, "propertyType" : PropertyType.NAME, "value" : (definition.hand == GloveHand.RIGHT ? "Glove - right" : "Glove - left") }); setProperty(context, { "entities" : glove, "propertyType" : PropertyType.APPEARANCE, "value" : color(0.12, 0.12, 0.12) }); }); // Point and unit tangent on the glove centreline at arc length s from the port: // straight cuff (length c) -> circular bend toward d (radius R, angle th) -> straight to the wrist. function spineAt(sp is map, s is ValueWithUnits) returns map { const A = sp.R * sp.th; if (s <= sp.c || sp.th < 1e-6) return { "point" : sp.O + s * sp.n, "tangent" : sp.n }; if (s <= sp.c + A) { const t = (s - sp.c) / sp.R; return { "point" : sp.O + sp.c * sp.n + sp.R * sin(t * radian) * sp.n + sp.R * (1 - cos(t * radian)) * sp.d, "tangent" : cos(t * radian) * sp.n + sin(t * radian) * sp.d }; } const endPt = sp.O + sp.c * sp.n + sp.R * sin(sp.th * radian) * sp.n + sp.R * (1 - cos(sp.th * radian)) * sp.d; const endTan = cos(sp.th * radian) * sp.n + sin(sp.th * radian) * sp.d; return { "point" : endPt + (s - sp.c - A) * endTan, "tangent" : endTan }; }