Move multiple beams ‘up to’

This code will move beams offset by different amounts up to a common beam or plane. It also showcases the pause feature in the code, which asks you to first select the beams to move, then the direction of travel, then the beam to move ‘up to’

Transparent Transparent

def handleaxis(dir):
    if dir == 0:
        return HandleAxis.X
    if dir == 1:
        return HandleAxis.Y
    if dir == 2:
        return HandleAxis.Z

result = Beta.InputHelper.PauseAndGetInput("Select Beams to move")
result2 = Beta.InputHelper.PauseAndGetInput("Select a Direction")
result3 = Beta.InputHelper.PauseAndGetInput("Select the target Beam")

if result.Success and isinstance(result.PrimarySelection.Items[0], DesignCurve) and result.PrimarySelection.Count > 0:
    source_selection = result.PrimarySelection.Items   
    if result2.Success and isinstance(result2.PrimarySelection.Items[0], CoordinateAxis):
        direction = result2.PrimarySelection.Items[0].AxisType.value__
        if result3.Success and isinstance(result3.PrimarySelection.Items[0], DesignCurve) and result3.PrimarySelection.Count==1:
            target_selection = result3.PrimarySelection.Items[0]

for beam in source_selection:
    selection = Selection.Create(beam)
    upToSelection = Selection.Create(target_selection)
    anchorPoint = Move.GetAnchorPoint(selection)
    moveFrame = Frame.Create(anchorPoint, Direction.DirX, Direction.DirY)
    axis = handleaxis(direction)
    Move.UpTo(selection, upToSelection, moveFrame, axis, MoveOptions())