import mathfrom AlibreScript import *# Initialize the part sessionpart = CurrentPart()# Define the dimensions of the bolthex_head_diameter = 10 # Diameter of the hex headhex_head_height = 5 # Height of the hex headshaft_diameter = 5 # Diameter of the shaftshaft_length = 20 # Length of the shaft# Create a hexagon sketch for the bolt headhex_sketch = part.AddSketch("HexHeadSketch", part.XYPlane)for i in range(6): angle1 = math.radians(60 * i) angle2 = math.radians(60 * (i + 1)) x1 = hex_head_diameter / 2 * math.cos(angle1) y1 = hex_head_diameter / 2 * math.sin(angle1) x2 = hex_head_diameter / 2 * math.cos(angle2) y2 = hex_head_diameter / 2 * math.sin(angle2) hex_sketch.AddLine([x1, y1], [x2, y2], False)# Extrude the hex headhex_head = part.AddExtrudeBoss("HexHead", hex_sketch, hex_head_height, False)# Create a circle sketch for the shaftshaft_sketch = part.AddSketch("ShaftSketch", part.XYPlane)shaft_sketch.AddCircle(0, 0, shaft_diameter / 2, False)# Extrude the shaftshaft = part.AddExtrudeBoss("Shaft", shaft_sketch, shaft_length, False)# Regenerate the part to update the viewpart.Regenerate()