// Robot Rotating Base

// Set Units
@settings(defaultLengthUnit = in, kclVersion = 1.0)

import axisJ1, baseHeight, plane001, plane002 from "globals.kcl"

// Create Rotating Base
sketch005 = startSketchOn(plane001)
  |> circle(center = [0, 0], radius = 3.9, tag = $referenceEdge1)
extrude005 = extrude(sketch005, length = 1.5 - 0.1)
  |> fillet(radius = 0.1, tags = [getOppositeEdge(referenceEdge1)])
  |> appearance(color = "#4f7d54", metalness = 90, roughness = 90)

sketch006 = startSketchOn(plane002)
  |> startProfile(at = [3.5, baseHeight])
  |> angledLine(angle = 60, length = 1.75)
  |> arc(angleStart = -30, angleEnd = -30 + 180, radius = 3)
  |> angledLine(angle = 60, endAbsoluteY = baseHeight)
  |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
  |> close()

extrude006 = extrude(sketch006, length = 1)

sketch007 = startSketchOn(extrude006, face = END)
  |> circle(
       center = [
         1.75 * cos(axisJ1) / abs(cos(axisJ1)),
         8
       ],
       radius = 2.75,
       tag = $referenceEdge2,
     )
extrude007 = extrude(sketch007, length = 1.5)
  |> fillet(radius = 0.1, tags = [getOppositeEdge(referenceEdge2)])

// Draw Bolt Pattern on Rotating Base
sketch008 = startSketchOn(extrude007, face = END)
  |> circle(
       center = [
         1.75 * cos(axisJ1) / abs(cos(axisJ1)),
         6.75
       ],
       radius = 0.2,
     )
  |> patternCircular2d(
       center = [
         1.75 * cos(axisJ1) / abs(cos(axisJ1)),
         8
       ],
       instances = 4,
       arcDegrees = 360,
       rotateDuplicates = true,
     )
extrude008 = extrude(sketch008, length = 0.2)

sketch009 = startSketchOn(extrude007, face = END)
  |> circle(
       center = [
         1.75 * cos(axisJ1) / abs(cos(axisJ1)),
         8
       ],
       radius = 0.5,
       tag = $referenceEdge3,
     )
extrude009 = extrude(sketch009, length = 0.15)
  |> fillet(radius = 0.1, tags = [getOppositeEdge(referenceEdge3)])
  |> appearance(color = "#4f7d54", metalness = 90, roughness = 90)

sketch010 = startSketchOn(plane002)
  |> circle(center = [1.75, 8], radius = 0.3)

extrude(sketch010, length = -1)
