ParaScript
workspace.para
Language
RUN SOLVER
DOWNLOAD STL
setup { name: "Remote", units: "mm", coordinate_system: "Z-up" } // Samsung remote. The body is a rounded slab. Keys, the ring, the rockers, // and the badge sit on that slab. The groove is cut into it. // Sizes are grouped by the part they describe. parameters { body: { radius: 21.0, straight: 134.0, thick: 14.0, bite: 1.0, // Raised parts sit this far below the top face, so the cap is not flush. rise: thick - bite }, keys: { radius: 4.5, height: 2.0 }, ring: { radius: 15.0, height: 2.2, bore: 7.6, bore_height: 4.2 }, select: { radius: 5.2, height: 2.6 }, rocker: { radius: 4.0, straight: 9.0, height: 2.0 }, groove: { width: 28.0, depth: 2.0, height: 3.0, sink: 1.2 }, badge: { width: 24.0, depth: 3.6, height: 1.4 }, layout: { power: { x: 0.0 - 9.0, y: 72.0 }, mic: { x: 9.0, y: 72.0 }, numbers: { x: 0.0 - 12.0, y: 58.0 }, back: { x: 0.0 - 13.0, y: 9.0 }, home: { x: 0.0, y: 9.0 }, play: { x: 13.0, y: 9.0 }, volume: { x: 0.0 - 12.0, y: 0.0 - 10.0 }, channel: { x: 12.0, y: 0.0 - 10.0 }, netflix: { x: 0.0 - 12.0, y: 0.0 - 35.0 }, tv: { x: 10.0, y: 0.0 - 33.0 }, disney: { x: 0.0 - 5.0, y: 0.0 - 49.0 }, prime: { x: 12.0, y: 0.0 - 49.0 }, ring: { x: 0.0, y: 33.0 }, groove: { x: 0.0, y: 0.0 - 24.0 }, badge: { x: 0.0, y: 0.0 - 74.0 } } } // pi is a value the whole script shares. def pi = 3.14159265359 def Stadium = radius => straight => height => Component( solid: coords => let half = straight / 2.0 in let top = Surface2D( max_u: radius * 2.0, min_v: u => 0.0, max_v: u => straight, formula: u => v => Vector(coords: coords, x: u - radius, y: v - half, z: height)) in let bottom = Surface2D( max_u: radius * 2.0, min_v: u => 0.0, max_v: u => straight, formula: u => v => Vector(coords: coords, x: u - radius, y: v - half, z: 0.0)) in let cap_top = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => radius, formula: u => v => Vector(coords: coords, x: v * cos(rad: u), y: half + (v * sin(rad: u)), z: height)) in let cap_bottom = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => radius, formula: u => v => Vector(coords: coords, x: v * cos(rad: u), y: 0.0 - half - (v * sin(rad: u)), z: height)) in let sole_top = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => radius, formula: u => v => Vector(coords: coords, x: v * cos(rad: u), y: half + (v * sin(rad: u)), z: 0.0)) in let sole_bottom = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => radius, formula: u => v => Vector(coords: coords, x: v * cos(rad: u), y: 0.0 - half - (v * sin(rad: u)), z: 0.0)) in let side_right = Surface2D( max_u: straight, min_v: u => 0.0, max_v: u => height, formula: u => v => Vector(coords: coords, x: radius, y: u - half, z: v)) in let side_left = Surface2D( max_u: straight, min_v: u => 0.0, max_v: u => height, formula: u => v => Vector(coords: coords, x: 0.0 - radius, y: u - half, z: v)) in let rim_top = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => height, formula: u => v => Vector(coords: coords, x: radius * cos(rad: u), y: half + (radius * sin(rad: u)), z: v)) in let rim_bottom = Surface2D( max_u: pi, min_v: u => 0.0, max_v: u => height, formula: u => v => Vector(coords: coords, x: radius * cos(rad: u), y: 0.0 - half - (radius * sin(rad: u)), z: v)) in Solid3D(faces: [ top, bottom, cap_top, cap_bottom, sole_top, sole_bottom, side_right, side_left, rim_top, rim_bottom ]), expose: coords => { up: Vector(coords: coords, x: 0.0, y: 0.0, z: 1.0), right: Vector(coords: coords, x: 1.0, y: 0.0, z: 0.0), corner: Vector(coords: coords, x: 0.0, y: 0.0, z: 0.0), bottom: Vector(coords: coords, x: 0.0, y: 0.0, z: 0.0) } ) def place_components = host => points => place => combine => fold( f: item => accumulator => Component( solid: join( frame: accumulator, placed: place, using: frame => placed => align( planar: meet(frame: accumulator.up, placed: placed.up), translation: meet(frame: accumulator.corner.add(vector: item), placed: placed.bottom), rotation: meet(frame: accumulator.right, placed: placed.right) ), combine: combine ), expose: coords => { up: accumulator.up, right: accumulator.right, corner: accumulator.corner } ), initial: host, list: points ) def Ring = Component( solid: join( frame: Cylinder(radius: $ring.radius, height: $ring.height), placed: Cylinder(radius: $ring.bore, height: $ring.bore_height), using: frame => placed => align( planar: meet(frame: frame.up, placed: placed.up), translation: meet(frame: frame.center, placed: placed.center), rotation: meet(frame: frame.right, placed: placed.right) ), combine: frame => placed => frame - placed ), expose: coords => { up: Vector(coords: coords, x: 0.0, y: 0.0, z: 1.0), right: Vector(coords: coords, x: 1.0, y: 0.0, z: 0.0), bottom: Vector(coords: coords, x: 0.0, y: 0.0, z: 0.0) } ) def Body = Stadium(radius: $body.radius, straight: $body.straight, height: $body.thick) def key_points = coords => [ Vector(coords: coords, x: $layout.power.x, y: $layout.power.y, z: $body.rise), Vector(coords: coords, x: $layout.mic.x, y: $layout.mic.y, z: $body.rise), Vector(coords: coords, x: $layout.numbers.x, y: $layout.numbers.y, z: $body.rise), Vector(coords: coords, x: $layout.back.x, y: $layout.back.y, z: $body.rise), Vector(coords: coords, x: $layout.home.x, y: $layout.home.y, z: $body.rise), Vector(coords: coords, x: $layout.play.x, y: $layout.play.y, z: $body.rise), Vector(coords: coords, x: $layout.netflix.x, y: $layout.netflix.y, z: $body.rise), Vector(coords: coords, x: $layout.tv.x, y: $layout.tv.y, z: $body.rise), Vector(coords: coords, x: $layout.disney.x, y: $layout.disney.y, z: $body.rise), Vector(coords: coords, x: $layout.prime.x, y: $layout.prime.y, z: $body.rise) ] def BodyWithGroove = coords => place_components( host: Body, points: [Vector(coords: coords, x: $layout.groove.x, y: $layout.groove.y, z: $body.thick - $groove.sink)], place: Box(width: $groove.width, depth: $groove.depth, height: $groove.height), combine: frame => placed => frame - placed ) def BodyWithKeys = coords => place_components( host: BodyWithGroove(coords: coords), points: key_points(coords: coords), place: Cylinder(radius: $keys.radius, height: $keys.height), combine: frame => placed => frame + placed ) def BodyWithRing = coords => place_components( host: BodyWithKeys(coords: coords), points: [Vector(coords: coords, x: $layout.ring.x, y: $layout.ring.y, z: $body.rise)], place: Ring, combine: frame => placed => frame + placed ) def BodyWithSelect = coords => place_components( host: BodyWithRing(coords: coords), points: [Vector(coords: coords, x: $layout.ring.x, y: $layout.ring.y, z: $body.rise)], place: Cylinder(radius: $select.radius, height: $select.height), combine: frame => placed => frame + placed ) def BodyWithRockers = coords => place_components( host: BodyWithSelect(coords: coords), points: [ Vector(coords: coords, x: $layout.volume.x, y: $layout.volume.y, z: $body.rise), Vector(coords: coords, x: $layout.channel.x, y: $layout.channel.y, z: $body.rise) ], place: Stadium(radius: $rocker.radius, straight: $rocker.straight, height: $rocker.height), combine: frame => placed => frame + placed ) def Remote = coords => place_components( host: BodyWithRockers(coords: coords), points: [Vector(coords: coords, x: $layout.badge.x, y: $layout.badge.y, z: $body.rise)], place: Box(width: $badge.width, depth: $badge.depth, height: $badge.height), combine: frame => placed => frame + placed ) export(Component( solid: coords => Remote(coords: coords) expose: coords => { origin: Vector(coords: coords, x: 0.0, y: 0.0, z: $body.thick / 2.0) } ))
Model
Solid sides
Drag to turn. Pinch to zoom. Two fingers pan.