Last active
February 3, 2023 04:51
-
-
Save trabulium/71365c71dd51df81481f192f46783b17 to your computer and use it in GitHub Desktop.
ChatGPT output of an adaptor plate for a Nema17 stepper motor for FreeCAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FreeCAD | |
import Part | |
def create_adapter_plate(): | |
# Define Nema17 dimensions | |
width = 42.3 | |
length = 42.3 | |
bolt_diameter = 4.0 | |
shaft_diameter = 5.0 | |
height = 10.0 | |
bolt_distance = 31.0 | |
# Define the plate shape | |
plate = Part.makePlane(width, length) | |
# Cut holes for bolts | |
hole_positions = [(width/2-bolt_distance/2, length/2-bolt_distance/2), | |
(width/2-bolt_distance/2, length/2+bolt_distance/2), | |
(width/2+bolt_distance/2, length/2-bolt_distance/2), | |
(width/2+bolt_distance/2, length/2+bolt_distance/2)] | |
for pos in hole_positions: | |
hole = Part.makeCylinder(bolt_diameter/2, height) | |
hole.translate(FreeCAD.Vector(*pos, 0)) | |
plate = plate.cut(hole) | |
# Cut hole for shaft | |
shaft_hole = Part.makeCylinder(shaft_diameter/2, height) | |
shaft_hole.translate(FreeCAD.Vector(width/2, length/2, 0)) | |
plate = plate.cut(shaft_hole) | |
# Extrude plate to 10mm height | |
plate = plate.extrude(FreeCAD.Vector(0, 0, height)) | |
# Create Part object and add it to the FreeCAD document | |
Part.show(plate) | |
create_adapter_plate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment