Skip to content

Instantly share code, notes, and snippets.

@beardicus
Last active March 6, 2024 22:23
Show Gist options
  • Select an option

  • Save beardicus/d668c0f6b96be53d16dc to your computer and use it in GitHub Desktop.

Select an option

Save beardicus/d668c0f6b96be53d16dc to your computer and use it in GitHub Desktop.
Plotter Pen Adapter for use with OpenJSCAD
// title : Plotter Pen Adapter
// author : Brian Boucheron <[email protected]>
// license : MIT License
// revision : 0.002
// date : February 9, 2016
// file : plotter-pen-adapter.jscad
// gist : https://gist.github.com/beardicus/d668c0f6b96be53d16dc
// A parametric version of the plotter pen adapter found here:
// https://www.thingiverse.com/thing:229982
//
// This is designed to be loaded into OpenJSCAD by visiting the following URL:
// http://openjscad.org/#https://gist.github.com/beardicus/d668c0f6b96be53d16dc/raw/plotter-pen-adapter.jscad
//
// The default parameters (in mm) are based on the Sharpie Fine Point pen,
// but can be tweaked for your particular pen, and are explained below. Enjoy,
// and get in touch with @bertmb and #plottertwitter
//
// Inner Diameter: this should be your pen's diameter, plus a little wiggle.
// You'll have to experiment for a good friction fit
//
// Outer Diameter: measured diameter of a real plotter pen is actually 11.5mm
// I bumped it for a thicker printable wall. There's probably some wiggle room.
//
// Barrel Length: how long of a barrel or "sleeve" do you want?
//
// Ring Height: height to bottom of the retaining ring (NOT midline)
// import giblets
const { cylinder, polygon } = require('@jscad/modeling').primitives
const { difference, union } = require('@jscad/modeling').booleans
const { rotateExtrude } = require('@jscad/modeling').extrusions
const { rotate } = require('@jscad/modeling').transforms
// build a profile for the retaining ring
ring_thickness = 2; // thickest point of the ring
ring_edge_thickness = 0.6; // thickness at the very edge of the ring
ring_diameter = 16.5; // diameter of the ring
ring_edge_diameter = 15; // diameter where ring starts to bevel
profile = [
[1, 0],
[ring_edge_diameter / 2, 0],
[ring_diameter / 2, (ring_thickness - ring_edge_thickness) / 2],
[ring_diameter / 2, ring_thickness - ((ring_thickness - ring_edge_thickness) / 2)],
[ring_edge_diameter / 2, ring_thickness],
[1, ring_thickness],
];
// get parameters
const getParameterDefinitions = () => {
return [{
name: 'penDiameter',
type: 'float',
initial: 10.8,
caption: "Inner Diamter"
}, {
name: 'adapterDiamter',
type: 'float',
initial: 11.6,
caption: "Outer Diameter"
}, {
name: 'barrelLength',
type: 'float',
initial: 20.7,
caption: "Barrel Length"
}, {
name: 'ringHeight',
type: 'float',
initial: 11,
caption: "Ring Height"
}];
}
// FIRE THE SPATIAL GEOMETRON
const main = (params) => {
return difference(
union(
rotate_extrude({fn: 50}, polygon({points: profile})).translate([0, 0, params.ringHeight]),
cylinder({r: params.adapterDiamter / 2, h: params.barrelLength, fn: 50})
),
cylinder({r: params.penDiameter / 2, h: 50, fn: 50})
);
}
module.exports = { main }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment