OpenSCAD

1 program Added 2025-10-22T15:23:45Z Model: anthropic/claude-3.5-sonnetTemp: 0.4 Evidence Report issue View issues
Aliases: SCAD
Provenance: commit 78b2aec565 · authored 2025-10-22T17:23:45+02:00 · model anthropic/claude-3.5-sonnet

Sources mentioning this language

6 sources · pl_id: pl/openscad
LLM (this repo) · 1PldbLinguistPygmentsHyperpolyglotRosettacode

Extensions claimed by this language

2 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.scadlinguistprimary413.5K files
.scadpygmentsprimary413.5K files

Related languages

OpenScript (0.25)OpenABL (0.24)OpenACC (0.24)OpenLisp (0.22)oK (0.21)

LLM-contributed programs

Customizable Gear Generator

Provenance: commit 78b2aec565 · authored 2025-10-22T17:23:45+02:00 · model anthropic/claude-3.5-sonnet · Temp 0.4
code.scad · license: LGPL-2.1 · added: 2025-10-22T15:23:45Z
// Parametric Involute Bevel and Spur Gears by GregFrost
// It is licensed under the Creative Commons - GNU LGPL 2.1 license.
// © 2010 by GregFrost, thingiverse.com/Amp
// http://www.thingiverse.com/thing:3575

// Simple Test:
test_bevel_gears();

module test_bevel_gears()
{
    bevel_gear_pair (gear1_teeth=41,
    gear2_teeth=7,
    axis_angle=90,
    outside_circular_pitch=460);
}

module bevel_gear_pair (gear1_teeth = 41,
    gear2_teeth = 7,
    axis_angle = 90,
    outside_circular_pitch=1000)
{
    outside_pitch_radius1 = gear1_teeth * outside_circular_pitch / 360;
    outside_pitch_radius2 = gear2_teeth * outside_circular_pitch / 360;
    pitch_apex1=outside_pitch_radius2 * sin(axis_angle)
        + (outside_pitch_radius2 * cos(axis_angle) + outside_pitch_radius1) / tan(axis_angle);
    cone_distance = sqrt(pow(pitch_apex1, 2) + pow(outside_pitch_radius1, 2));
    pitch_apex2 = sqrt(pow(cone_distance, 2) - pow(outside_pitch_radius2, 2));
    echo("cone_distance", cone_distance);
    pitch_angle1 = asin(outside_pitch_radius1 / cone_distance);
    pitch_angle2 = asin(outside_pitch_radius2 / cone_distance);
    echo("pitch_angle1, pitch_angle2", pitch_angle1, pitch_angle2);
    rotate([0,0,90])
    translate([0,0,pitch_apex1])
    rotate([-pitch_angle1,0,0])
    bevel_gear (number_of_teeth=gear1_teeth,
        cone_distance=cone_distance,
        face_width=10,
        outside_circular_pitch=outside_circular_pitch,
        pressure_angle=30,
        clearance = 0.2,
        bore_diameter=5);
}

Real programs from Software Heritage

2 samples mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
queues.scad · 6169 B · ext .scad · seen 422× in SWH
via unique-primary
swh:1:cnt:cb346c02d24adb946a7837e8709efd3f386e8bc5;origin=https://github.com/johntron/johntron;anchor=swh:1:rev:38b832b5a89d0e596ab26a1b7867f3abb77717fe;path=/projects/prusa-enclosure/BOSL2/queues.scad
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
//////////////////////////////////////////////////////////////////////
// LibFile: queues.scad
//   Queue data structure implementation.
//   To use, add the following lines to the beginning of your file:
//   ```
//   use <BOSL2/std.scad>
//   use <BOSL2/queues.scad>
//   ```
//////////////////////////////////////////////////////////////////////


// Section: Queue Data Structure
//   A queue is a first-in-first-out collection of items.  You can add items onto the tail of the
//   queue, or pop items off the head.  While you can treat a queue as an opaque data type, using the
//   functions below, it's simply implemented as a list.  This means that you can use any list
//   function to manipulate the queue.  The first item in the list is the head queue item.


// Function: queue_init()
// Usage:
//   queue = queue_init();
// Description:
//   Creates an empty queue/list.
// Example:
//   queue = queue_init();  // Return: []
function queue_init() = [];


// Function: queue_empty()
// Usage:
//   if (queue_empty(queue)) ...
// Description:
//   Returns true if the given queue is empty.
// Arguments:
//   queue = The queue to test if empty.
// Example:
//   queue = queue_init();
//   is_empty = queue_empty(queue);  // Returns: true
//   queue2 = queue_add(queue, "foo");
//   is_empty2 = queue_empty(queue2);  // Returns: false
function queue_empty(queue) =
	assert(is_list(queue))
	len(queue)==0;


// Function: queue_size()
// Usage:
//   depth = queue_size(queue);
// Description:
//   Returns the number of items in the given queue.
// Arguments:
//   queue = The queue to get the size of.
// Example:
//   queue = queue_init();
//   depth = queue_size(queue);  // Returns: 0
//   queue2 = queue_add(queue, "foo");
//   depth2 = queue_size(queue2);  // Returns: 1
//   queue3 = queue_add(queue2, ["bar","baz","qux"]);
//   depth3 = queue_size(queue3);  // Returns: 4
function queue_size(queue) =
	assert(is_list(queue))
	len(queue);


// Function: queue_head()
// Usage:
//   item = queue_head(queue);
//   list = queue_head(queue,n);
// Description:
//   If `n` is not given, returns the first item from the head of the queue.
//   If `n` is given, returns a list of the first `n` items from the head of the queue.
// Arguments:
//   queue = The queue/list to get item(s) from the head of.
// Example:
//   queue = [4,5,6,7,8,9];
//   item = queue_head(queue);  // Returns: 4
//   list = queue_head(queue,n=3);  // Returns: [4,5,6]
function queue_head(queue,n=undef) =
	assert(is_list(queue))
	is_undef(n)? (
		queue[0]
	) : (
		let(queuesize = len(queue))
		assert(is_num(n))
		assert(n>=0)
		assert(queuesize>=n, "queue underflow")
		[for (i=[0:1:n-1]) queue[i]]
	);


// Function: queue_tail()
// Usage:
//   item = queue_tail(queue);
//   list = queue_tail(queue,n);
// Description:
//   If `n` is not given, returns the last item from the tail of the queue.
//   If `n` is given, returns a list of the last `n` items from the tail of the queue.
// Arguments:
//   queue = The queue/list to get item(s) from the tail of.
// Example:
//   queue = [4,5,6,7,8,9];
//   item = queue_tail(queue);  // Returns: 9
//   list = queue_tail(queue,n=3);  // Returns: [7,8,9]
function queue_tail(queue,n=undef) =
	assert(is_list(queue))
	let(queuesize = len(queue))
	is_undef(n)? (
		queue[queuesize-1]
	) : (
		assert(is_num(n))
		assert(n>=0)
		assert(queuesize>=n, "queue underflow")
		[for (i=[0:1:n-1]) queue[queuesize-n+i]]
	);


// Function: queue_peek()
// Usage:
//   item = queue_peek(queue,[pos]);
//   list = queue_peek(queue,pos,n);
// Description:
//   If `n` is not given, returns the queue item at position `pos`.
//   If `n` is given, returns a list of the `n` queue items at and after position `pos`.
// Arguments:
//   queue = The queue to read from.
//   pos = The position of the queue item to read.  Default: 0
//   n = The number of queue items to return.  Default: undef (Return only the queue item at `pos`)
// Example:
//   queue = [2,3,4,5,6,7,8,9];
//   item = queue_peek(queue);  // Returns: 2
//   item2 = queue_peek(queue, 3);  // Returns: 5
//   list = queue_peek(queue, 4, 3);  // Returns: [6,7,8]
function queue_peek(queue,pos=0,n=undef) =
	assert(is_list(queue))
	assert(is_num(pos))
	assert(pos>=0)
	let(queuesize = len(queue))
	assert(queuesize>=pos, "queue underflow")
	is_undef(n)? (
		queue[pos]
	) : (
		assert(is_num(n))
		assert(n>=0)
		assert(n<queuesize-pos)
		[for (i=[0:1:n-1]) queue[pos+i]]
	);


// Function: queue_add()
// Usage:
//   modified_queue = queue_add(queue,items);
// Description:
//   Adds the given `items` onto the queue `queue`.  Returns the modified queue.
// Arguments:
//   queue = The queue to modify.
//   items = A value or list of values to add to the queue.
// Example:
//   queue = [4,9,2,3];
//   queue2 = queue_add(queue,7);  // Returns: [4,9,2,3,7]
//   queue3 = queue_add(queue2,[6,1]);  // Returns: [4,9,2,3,7,6,1]
//   queue4 = queue_add(queue,[[5,8]]);  // Returns: [4,9,2,3,[5,8]]
//   queue5 = queue_add(queue,[[5,8],6,7]);  // Returns: [4,9,2,3,[5,8],6,7]
// Example: Typical Producer and Consumer
//   q2 = queue_add(q, "foo");
//   ...
//   val = queue_head(q2);
//   q3 = queue_pop(q2);
function queue_add(queue,items) =
	assert(is_list(queue))
	is_list(items)? concat(queue, items) : concat(queue, [items]);


// Function: queue_pop()
// Usage:
//   modified_queue = queue_pop(queue, [n]);
// Description:
//   Removes `n` items from the head of the queue.  Returns the modified queue.
// Arguments:
//   queue = The queue to modify.
//   n = The number of items to remove from the head of the queue.  Default: 1
// Example:
//   queue = [4,5,6,7,8,9];
//   queue2 = queue_pop(queue);  // Returns: [5,6,7,8,9]
//   queue3 = queue_pop(queue2,n=3);  // Returns: [8,9]
// Example: Typical Producer and Consumer
//   q2 = queue_add(q, "foo");
//   ...
//   val = queue_head(q2);
//   q3 = queue_pop(q2);
function queue_pop(queue,n=1) =
	assert(is_list(queue))
	assert(is_num(n))
	assert(n>=0)
	let(queuesize = len(queue))
	assert(queuesize>=n, "queue underflow")
	[for (i = [n:1:queuesize-1]) queue[i]];



// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
nema_steppers.scad · 27637 B · ext .scad · seen 404× in SWH
via unique-primary
swh:1:cnt:2244806aaa1cfaea2e21cd06ac7fdaaf414b2b85;origin=https://github.com/tlouden/uplift-iot;anchor=swh:1:rev:b0f916ffa4c5ce3f818b08c0730c278e778bef3b;path=/enclosure/BOSL2/nema_steppers.scad
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
//////////////////////////////////////////////////////////////////////
// LibFile: nema_steppers.scad
//   Masks and models for NEMA stepper motors.
//   To use, add these lines to the top of your file:
//   ```
//   include <BOSL2/std.scad>
//   include <BOSL2/nema_steppers.scad>
//   ```
//////////////////////////////////////////////////////////////////////


// Section: Functions


// Function: nema_motor_width()
// Description: Gets width of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_width(size) = lookup(size, [
        [11.0, 28.2],
        [14.0, 35.2],
        [17.0, 42.3],
        [23.0, 57.0],
        [34.0, 86.0],
    ]);


// Function: nema_motor_plinth_height()
// Description: Gets plinth height of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_plinth_height(size) = lookup(size, [
        [11.0, 1.5],
        [14.0, 2.0],
        [17.0, 2.0],
        [23.0, 1.6],
        [34.0, 2.03],
    ]);


// Function: nema_motor_plinth_diam()
// Description: Gets plinth diameter of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_plinth_diam(size) = lookup(size, [
        [11.0, 22.0],
        [14.0, 22.0],
        [17.0, 22.0],
        [23.0, 38.1],
        [34.0, 73.0],
    ]);


// Function: nema_motor_screw_spacing()
// Description: Gets screw spacing of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_screw_spacing(size) = lookup(size, [
        [11.0, 23.11],
        [14.0, 26.0],
        [17.0, 30.99],
        [23.0, 47.14],
        [34.0, 69.6],
    ]);


// Function: nema_motor_screw_size()
// Description: Gets mount screw size of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_screw_size(size) = lookup(size, [
        [11.0, 2.6],
        [14.0, 3.0],
        [17.0, 3.0],
        [23.0, 5.1],
        [34.0, 5.5],
    ]);


// Function: nema_motor_screw_depth()
// Description: Gets mount screw-hole depth of NEMA motor of given standard size.
// Arguments:
//   size = The standard NEMA motor size.
function nema_motor_screw_depth(size) = lookup(size, [
        [11.0, 3.0],
        [14.0, 4.5],
        [17.0, 4.5],
        [23.0, 4.8],
        [34.0, 9.0],
    ]);


// Section: Motor Models


// Module: nema11_stepper()
// Description: Creates a model of a NEMA 11 stepper motor.
// Arguments:
//   h = Length of motor body.  Default: 24mm
//   shaft = Shaft diameter. Default: 5mm
//   shaft_len = Length of shaft protruding out the top of the stepper motor.  Default: 20mm
//   anchor = Translate so anchor point is at origin (0,0,0).  See [anchor](attachments.scad#anchor).  Default: `CENTER`
//   spin = Rotate this many degrees around the Z axis after anchor.  See [spin](attachments.scad#spin).  Default: `0`
//   orient = Vector to rotate top towards, after spin.  See [orient](attachments.scad#orient).  Default: `UP`
// Extra Anchors:
//   "shaft-top" = The top of the shaft.
//   "shaft-middle" = The middle of the shaft.
//   "shaft-bottom" = The bottom of the shaft, 0.1mm above the plinth.
//   "plinth-top" = The top of the plinth.
//   "screw1" = The screw-hole in the X+Y+ quadrant.
//   "screw2" = The screw-hole in the X-Y+ quadrant.
//   "screw3" = The screw-hole in the X-Y- quadrant.
//   "screw4" = The screw-hole in the X+Y- quadrant.
// Example:
//   nema11_stepper();
module nema11_stepper(h=24, shaft=5, shaft_len=20, anchor=TOP, spin=0, orient=UP)
{
    size = 11;
    motor_width = nema_motor_width(size);
    plinth_height = nema_motor_plinth_height(size);
    plinth_diam = nema_motor_plinth_diam(size);
    screw_spacing = nema_motor_screw_spacing(size);
    screw_size = nema_motor_screw_size(size);
    screw_depth = nema_motor_screw_depth(size);

    anchors = [
        anchorpt("shaft-top", [0,0,h/2+shaft_len]),
        anchorpt("shaft-middle", [0,0,h/2+plinth_height+(shaft_len-plinth_height)/2]),
        anchorpt("shaft-bottom", [0,0,h/2+plinth_height+0.1]),
        anchorpt("plinth-top", [0,0,h/2+plinth_height]),
        anchorpt("screw1", [+screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw2", [-screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw3", [-screw_spacing/2, -screw_spacing/2, h/2]),
        anchorpt("screw4", [+screw_spacing/2, -screw_spacing/2, h/2]),
    ];
    attachable(anchor,spin,orient, size=[motor_width, motor_width, h], anchors=anchors) {
        up(h/2)
        union() {
            difference() {
                color([0.4, 0.4, 0.4]) 
                    cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
                color("silver")
                    xcopies(screw_spacing)
                        ycopies(screw_spacing)
                            cyl(r=screw_size/2, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
            }
            color([0.6, 0.6, 0.6]) {
                difference() {
                    cylinder(h=plinth_height, d=plinth_diam);
                    cyl(h=plinth_height*3, d=shaft+0.75);
                }
            }
            color("silver") cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
        }
        children();
    }
}



// Module: nema14_stepper()
// Description: Creates a model of a NEMA 14 stepper motor.
// Arguments:
//   h = Length of motor body.  Default: 24mm
//   shaft = Shaft diameter. Default: 5mm
//   shaft_len = Length of shaft protruding out the top of the stepper motor.  Default: 24mm
//   anchor = Translate so anchor point is at origin (0,0,0).  See [anchor](attachments.scad#anchor).  Default: `CENTER`
//   spin = Rotate this many degrees around the Z axis after anchor.  See [spin](attachments.scad#spin).  Default: `0`
//   orient = Vector to rotate top towards, after spin.  See [orient](attachments.scad#orient).  Default: `UP`
// Extra Anchors:
//   "shaft-top" = The top of the shaft.
//   "shaft-middle" = The middle of the shaft.
//   "shaft-bottom" = The bottom of the shaft, 0.1mm above the plinth.
//   "plinth-top" = The top of the plinth.
//   "screw1" = The screw-hole in the X+Y+ quadrant.
//   "screw2" = The screw-hole in the X-Y+ quadrant.
//   "screw3" = The screw-hole in the X-Y- quadrant.
//   "screw4" = The screw-hole in the X+Y- quadrant.
// Example:
//   nema14_stepper();
module nema14_stepper(h=24, shaft=5, shaft_len=24, anchor=TOP, spin=0, orient=UP)
{
    size = 14;
    motor_width = nema_motor_width(size);
    plinth_height = nema_motor_plinth_height(size);
    plinth_diam = nema_motor_plinth_diam(size);
    screw_spacing = nema_motor_screw_spacing(size);
    screw_size = nema_motor_screw_size(size);
    screw_depth = nema_motor_screw_depth(size);

    anchors = [
        anchorpt("shaft-top", [0,0,h/2+shaft_len]),
        anchorpt("shaft-middle", [0,0,h/2+plinth_height+(shaft_len-plinth_height)/2]),
        anchorpt("shaft-bottom", [0,0,h/2+plinth_height+0.1]),
        anchorpt("plinth-top", [0,0,h/2+plinth_height]),
        anchorpt("screw1", [+screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw2", [-screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw3", [-screw_spacing/2, -screw_spacing/2, h/2]),
        anchorpt("screw4", [+screw_spacing/2, -screw_spacing/2, h/2]),
    ];
    attachable(anchor,spin,orient, size=[motor_width, motor_width, h], anchors=anchors) {
        up(h/2)
        union() {
            difference() {
                color([0.4, 0.4, 0.4])
                    cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
                color("silver")
                    xcopies(screw_spacing)
                        ycopies(screw_spacing)
                            cyl(d=screw_size, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
            }
            color([0.6, 0.6, 0.6]) {
                difference() {
                    cylinder(h=plinth_height, d=plinth_diam);
                    cyl(h=plinth_height*3, d=shaft+0.75);
                }
            }
            color("silver") cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
        }
        children();
    }
}



// Module: nema17_stepper()
// Description: Creates a model of a NEMA 17 stepper motor.
// Arguments:
//   h = Length of motor body.  Default: 34mm
//   shaft = Shaft diameter. Default: 5mm
//   shaft_len = Length of shaft protruding out the top of the stepper motor.  Default: 20mm
//   anchor = Translate so anchor point is at origin (0,0,0).  See [anchor](attachments.scad#anchor).  Default: `CENTER`
//   spin = Rotate this many degrees around the Z axis after anchor.  See [spin](attachments.scad#spin).  Default: `0`
//   orient = Vector to rotate top towards, after spin.  See [orient](attachments.scad#orient).  Default: `UP`
// Extra Anchors:
//   "shaft-top" = The top of the shaft.
//   "shaft-middle" = The middle of the shaft.
//   "shaft-bottom" = The bottom of the shaft, 0.1mm above the plinth.
//   "plinth-top" = The top of the plinth.
//   "screw1" = The screw-hole in the X+Y+ quadrant.
//   "screw2" = The screw-hole in the X-Y+ quadrant.
//   "screw3" = The screw-hole in the X-Y- quadrant.
//   "screw4" = The screw-hole in the X+Y- quadrant.
// Example:
//   nema17_stepper();
module nema17_stepper(h=34, shaft=5, shaft_len=20, anchor=TOP, spin=0, orient=UP)
{
    size = 17;
    motor_width = nema_motor_width(size);
    plinth_height = nema_motor_plinth_height(size);
    plinth_diam = nema_motor_plinth_diam(size);
    screw_spacing = nema_motor_screw_spacing(size);
    screw_size = nema_motor_screw_size(size);
    screw_depth = nema_motor_screw_depth(size);

    anchors = [
        anchorpt("shaft-top", [0,0,h/2+shaft_len]),
        anchorpt("shaft-middle", [0,0,h/2+plinth_height+(shaft_len-plinth_height)/2]),
        anchorpt("shaft-bottom", [0,0,h/2+plinth_height+0.1]),
        anchorpt("plinth-top", [0,0,h/2+plinth_height]),
        anchorpt("screw1", [+screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw2", [-screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw3", [-screw_spacing/2, -screw_spacing/2, h/2]),
        anchorpt("screw4", [+screw_spacing/2, -screw_spacing/2, h/2]),
    ];
    attachable(anchor,spin,orient, size=[motor_width, motor_width, h], anchors=anchors) {
        up(h/2)
        union() {
            difference() {
                color([0.4, 0.4, 0.4])
                    cuboid([motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
                color("silver")
                    xcopies(screw_spacing)
                        ycopies(screw_spacing)
                            cyl(d=screw_size, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
            }
            color([0.6, 0.6, 0.6]) {
                difference() {
                    cylinder(h=plinth_height, d=plinth_diam);
                    cyl(h=plinth_height*3, d=shaft+0.75);
                }
            }
            color([0.9, 0.9, 0.9]) {
                down(h-motor_width/12) {
                    fwd(motor_width/2+motor_width/24/2-0.1) {
                        difference() {
                            cube(size=[motor_width/8, motor_width/24, motor_width/8], center=true);
                            cyl(d=motor_width/8-2, h=motor_width/6, orient=BACK, $fn=12);
                        }
                    }
                }
            }
            color("silver") {
                difference() {
                    cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
                    up(shaft_len/2+1) {
                        right(shaft-0.75) {
                            cube([shaft, shaft, shaft_len], center=true);
                        }
                    }
                }
            }
        }
        children();
    }
}



// Module: nema23_stepper()
// Description: Creates a model of a NEMA 23 stepper motor.
// Arguments:
//   h = Length of motor body.  Default: 50mm
//   shaft = Shaft diameter. Default: 6.35mm
//   shaft_len = Length of shaft protruding out the top of the stepper motor.  Default: 25mm
//   anchor = Translate so anchor point is at origin (0,0,0).  See [anchor](attachments.scad#anchor).  Default: `CENTER`
//   spin = Rotate this many degrees around the Z axis after anchor.  See [spin](attachments.scad#spin).  Default: `0`
//   orient = Vector to rotate top towards, after spin.  See [orient](attachments.scad#orient).  Default: `UP`
// Extra Anchors:
//   "shaft-top" = The top of the shaft.
//   "shaft-middle" = The middle of the shaft.
//   "shaft-bottom" = The bottom of the shaft, 0.1mm above the plinth.
//   "plinth-top" = The top of the plinth.
//   "screw1" = The screw-hole in the X+Y+ quadrant.
//   "screw2" = The screw-hole in the X-Y+ quadrant.
//   "screw3" = The screw-hole in the X-Y- quadrant.
//   "screw4" = The screw-hole in the X+Y- quadrant.
// Example:
//   nema23_stepper();
module nema23_stepper(h=50, shaft=6.35, shaft_len=25, anchor=TOP, spin=0, orient=UP)
{
    size = 23;
    motor_width = nema_motor_width(size);
    plinth_height = nema_motor_plinth_height(size);
    plinth_diam = nema_motor_plinth_diam(size);
    screw_spacing = nema_motor_screw_spacing(size);
    screw_size = nema_motor_screw_size(size);
    screw_depth = nema_motor_screw_depth(size);

    screw_inset = motor_width - screw_spacing + 1;
    anchors = [
        anchorpt("shaft-top", [0,0,h/2+shaft_len]),
        anchorpt("shaft-middle", [0,0,h/2+plinth_height+(shaft_len-plinth_height)/2]),
        anchorpt("shaft-bottom", [0,0,h/2+plinth_height+0.1]),
        anchorpt("plinth-top", [0,0,h/2+plinth_height]),
        anchorpt("screw1", [+screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw2", [-screw_spacing/2, +screw_spacing/2, h/2]),
        anchorpt("screw3", [-screw_spacing/2, -screw_spacing/2, h/2]),
        anchorpt("screw4", [+screw_spacing/2, -screw_spacing/2, h/2]),
    ];
    attachable(anchor,spin,orient, size=[motor_width, motor_width, h], anchors=anchors) {
        up(h/2)
        difference() {
            union() {
                color([0.4, 0.4, 0.4])
                    cuboid([motor_width, motor_width, h], chamfer=2, edges=edges("Z"), anchor=TOP);
                color([0.4, 0.4, 0.4])
                    cylinder(h=plinth_height, d=plinth_diam);
                color("silver")
                    cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
            }
            color([0.4, 0.4, 0.4]) {
                xcopies(screw_spacing) {
                    ycopies(screw_spacing) {
                        cyl(d=screw_size, h=screw_depth*3, $fn=max(12,segs(screw_size/2)));
                        down(screw_depth) cuboid([screw_inset, screw_inset, h], anchor=TOP);
                    }
                }
            }
        }
        children();
    }
}



// Module: nema34_stepper()
// Description: Creates a model of a NEMA 34 stepper motor.
// Arguments:
//   h = Length of motor body.  Default: 75mm
//   shaft = Shaft diameter. Default: 12.7mm
//   shaft_len = Length of shaft protruding out the top of the stepper motor.  Default: 32mm
//   anchor = Translate so anchor point is at origin (0,0,0).  See [anchor](attachments.scad#anchor).  Default: `CENTER`
//   spin = Rotate this many degrees around the Z axis after anchor.  See [spin](attachments.scad#spin).  Default: `0`
//   orient = Vector to rotate top towards, after spin.  See [orient](attachments.scad#orient).  Default: `UP`
// Extra Anchors:
//   "shaft-top" = The top of the shaft.
//   "shaft-middle" = The middle of the shaft.
//   "shaft-bottom" = The bottom of the shaft, 0.1mm above the plinth.
//   "plinth-top" = The top of the plinth.
//   "screw1" = The screw-hole in the X+Y+ quadrant.
//   "screw2" = The screw-hole in the X-Y+ quadrant.
//   "screw3" = The sc
…(truncated)…

Contribute — propose a file extension

Tell us where to find evidence about OpenSCAD (mapped to pl/openscad). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/OpenSCAD/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← OpenROAD OpenScript →