Bolt Creator


This script does the following:

  1. Creates a new part called My Part
  2. Creates a simple bolt with a cap head featuring a hexagonal recess based on the dimensions in the code
  3. Saves the part to a directory (commented out - replace with your directory)
  4. Exports an STL to a directory (commented out - replace with your directory)
  5. Closes the newly created part


MyPart = Part('My Part')
 
XYPlane = MyPart.GetPlane('XY-Plane')
HeadSketch = MyPart.AddSketch('Head', XYPlane)
HeadSketch.AddCircle(0, 0, 10, False)
BoltHead = MyPart.AddExtrudeBoss('Bolt Head', HeadSketch, 5, False)
 
HeadBottomPlane = MyPart.AddPlane('Head Bottom', XYPlane, 5)
ShoulderSketch = MyPart.AddSketch('Shoulder', HeadBottomPlane)
ShoulderSketch.AddCircle(0, 0, 5, False)
BoltShoulder = MyPart.AddExtrudeBoss('Bolt Shoulder', ShoulderSketch, 20, False)
 
HexSketch = MyPart.AddSketch('Hex', XYPlane)
HexSketch.AddPolygon(0, 0, 5, 6, False)
HexRecess = MyPart.AddExtrudeCut('Hex Recess', HexSketch, 3, False)
 
# save and export, replace paths with your own
#Remove the "#" from the lines below to make them active

#MyPart.Save('C:\Users\YourUserName\Desktop')
#MyPart.ExportSTL('C:\Users\YourUserName\Desktop\My Part.stl')
#MyPart.Close()


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.