from aqa.math import *
from varmain.primitiv import *
from varmain.custom import *

# RK: ReferenceSize = DN50
# RK: Dimension = L | A | face-to-face length | 1
# RK: Dimension = BodyRadius | D | body radius derived from outside diameter | 1
@activate(Group='Valve', TooltipShort='Example valve', LengthUnit='mm', Ports='2', FirstPortEndtypes='FL')
@group('Dimensions')
@param(L=LENGTH0)
@param(BodyRadius=LENGTH0)
@param(BoreRadius=LENGTH0)
def CPVExampleValve(s, L=150.0, BodyRadius=40.0, BoreRadius=20.0, ID='CPVExampleValve', **kw):
    body = CYLINDER(s, R=BodyRadius, H=L, O=0.0).rotateY(90)
    bore = CYLINDER(s, R=BoreRadius, H=L, O=0.0).rotateY(90)
    body.subtractFrom(bore)
    bore.erase()
    # S1: Inlet
    s.setPoint((0, 0, 0), (-1, 0, 0))
    # S2: Outlet
    s.setPoint((L, 0, 0), (1, 0, 0))
