Created
February 3, 2023 04:52
-
-
Save trabulium/2d11df4a284fd1d716ca5da04867db48 to your computer and use it in GitHub Desktop.
chatGPT 1st Attempt to create FreeCAD adaptor for Nema17
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 | |
# Define the plate shape | |
plate = Part.makePlane(width, length) | |
# Cut holes for bolts | |
hole_positions = [(width/2-bolt_diameter/2, length/2-bolt_diameter/2), | |
(width/2-bolt_diameter/2, length/2+bolt_diameter/2), | |
(width/2+bolt_diameter/2, length/2-bolt_diameter/2), | |
(width/2+bolt_diameter/2, length/2+bolt_diameter/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