Open
Description
/* Generated by Text-to-CAD:
the controller for a nintendo switch */
@settings(defaultLengthUnit = mm)
// Define dimensions
controllerWidth = 50
controllerHeight = 173
controllerDepth = 14
buttonRadius = 5
joystickRadius = 10
joystickBaseHeight = 3
joystickHeight = 15
dpadSize = 20
dpadThickness = 2
buttonSpacing = 15
// Create the main body of the controller
controllerBody = startSketchOn(XY)
|> startProfile(at = [
-controllerWidth / 2,
-controllerHeight / 2
])
|> xLine(length = controllerWidth)
|> yLine(length = controllerHeight)
|> xLine(length = -controllerWidth)
|> close()
|> extrude(length = controllerDepth)
// Create the left joystick
leftJoystickBase = startSketchOn(controllerBody, face = END)
|> circle(
center = [
-controllerWidth / 4,
controllerHeight / 4
],
radius = joystickRadius,
)
|> extrude(length = joystickBaseHeight)
leftJoystick = startSketchOn(leftJoystickBase, face = END)
|> circle(
center = [
-controllerWidth / 4,
controllerHeight / 4
],
radius = joystickRadius - 2,
)
|> extrude(length = joystickHeight)
// Create the right joystick
rightJoystickBase = startSketchOn(controllerBody, face = END)
|> circle(
center = [
controllerWidth / 4,
controllerHeight / 4
],
radius = joystickRadius,
)
|> extrude(length = joystickBaseHeight)
rightJoystick = startSketchOn(rightJoystickBase, face = END)
|> circle(
center = [
controllerWidth / 4,
controllerHeight / 4
],
radius = joystickRadius - 2,
)
|> extrude(length = joystickHeight)
// Create the D-pad
sketch001 = startSketchOn(controllerBody, face = END)
dpad = startProfile(sketch001, at = [-3.15, -43.88])
|> yLine(length = dpadSize / 2)
|> xLine(length = dpadSize / 2)
|> yLine(length = -dpadSize / 2)
|> xLine(length = dpadSize / 2)
|> yLine(length = -dpadSize / 2)
|> xLine(length = -dpadSize / 2)
|> yLine(length = -dpadSize / 2)
|> xLine(length = -dpadSize / 2)
|> yLine(length = dpadSize / 2)
|> xLine(length = -dpadSize / 2)
|> yLine(length = dpadSize / 2)
|> close()
dpad
|> extrude(length = dpadThickness)
// Create the buttons
buttonPositions = [
[-buttonSpacing, -buttonSpacing],
[buttonSpacing, -buttonSpacing],
[-buttonSpacing, buttonSpacing],
[buttonSpacing, buttonSpacing]
]
buttons = map(
buttonPositions,
f = fn(@pos) {
return startSketchOn(controllerBody, face = END)
|> circle(center = pos, radius = buttonRadius)
|> extrude(length = buttonRadius)
},
)