Skip to content

Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel

2.5 KB
Raw Blame
// One exact pickup part; all construction coordinates are local to its Mount.
Record PickupSpec {
  width: Length; depth: Length; baseHeight: Length
  coilWidth: Length; coilDepth: Length; coilHeight: Length
  coilOffset: Length; polePitch: Length
}
Static StandardPickup: PickupSpec {
  width: 88mm; depth: 46mm; baseHeight: 4mm
  coilWidth: 70mm; coilDepth: 17mm; coilHeight: 5mm
  coilOffset: 10mm; polePitch: 10.2mm
}
Static BridgePickupSpec = StandardPickup with { polePitch: 10.2mm }

Feature Coil(center: Point2, width: Length, depth: Length, height: Length, support: Plane) -> Boss {
  RoundedRect2 outline { center: center; size: [width, depth]; radius: 3mm }
  Profile section { Loop Outer { outline |> TraceLoop } }
  return Boss { on: support; profile: section; height: height }
}
Feature Pole(center: Point2, support: Plane) -> Boss {
  Circle2 outline { center: center; radius: 2.2mm }
  Profile section { Loop Outer { outline |> TraceLoop } }
  return Boss { on: support; profile: section; height: 1mm }
}

Template<Spec: PickupSpec> Struct Humbucker {
  Concept Struct layout on XY {
    Point2 upperCenter { position: [0mm, Spec.coilOffset] }
    Point2 lowerCenter { position: [0mm, -Spec.coilOffset] }
    Axis2 longitudinal { origin: [0mm, 0mm]; direction: [1, 0] }
    Axis2 transverse { origin: [0mm, 0mm]; direction: [0, 1] }
    Point2 firstPole { position: [-2.5 * Spec.polePitch, Spec.coilOffset] }
    RoundedRect2 baseOutline { center: [0mm, 0mm]; size: [Spec.width, Spec.depth]; radius: 4mm }
  }
  Profile baseProfile using layout { Loop Outer { baseOutline |> TraceLoop } }
  Plane baseTop { origin: [0mm, 0mm, Spec.baseHeight]; normal: [0, 0, 1]; up: [0, 1, 0] }
  Plane coilTop { origin: [0mm, 0mm, Spec.baseHeight + Spec.coilHeight]; normal: [0, 0, 1]; up: [0, 1, 0] }
  Compose Body {
    Base housing { profile: baseProfile; from: 0mm; to: Spec.baseHeight; role: Stock }
    Feature upperCoil = Coil(center: layout.upperCenter, width: Spec.coilWidth, depth: Spec.coilDepth, height: Spec.coilHeight, support: baseTop)
    Feature lowerCoil = Coil(center: layout.lowerCenter, width: Spec.coilWidth, depth: Spec.coilDepth, height: Spec.coilHeight, support: baseTop)
    Feature poleSeed = Pole(center: layout.firstPole, support: coilTop)
    Linear Pattern poles {
      source: poleSeed
      direction: layout.longitudinal.Direction
      count: 6
      spacing: Spec.polePitch
    }
  }
  expose { Semantic Mount { DatumFrame Frame = [0mm, 0mm, 0mm] x [1, 0, 0] y [0, 1, 0] z [0, 0, 1]; } }
}