(
    delete objects
    global g_dist = 20.0
    global g_z    = 10.0
    global g_size =  8.0
    global g_busy = false

    -- ヘルパー生成
    global g_A1 = point name:"A1" pos:[0,  g_dist,  g_z] size:g_size wirecolor:red   cross:true
    global g_B1 = point name:"B1" pos:[0,      0,  g_z] size:g_size wirecolor:blue  cross:true
    global g_C1 = point name:"C1" pos:[0, -g_dist,  g_z] size:g_size wirecolor:green cross:true

    global g_A2 = point name:"A2" pos:[g_dist,  g_dist,  g_z] size:g_size wirecolor:orange cross:true
    global g_B2 = point name:"B2" pos:[g_dist,       0,  g_z] size:g_size wirecolor:yellow cross:true
    global g_C2 = point name:"C2" pos:[g_dist, -g_dist,  g_z] size:g_size wirecolor:(color 0 255 255) cross:true

    -- 親行を固定
    for p in #(g_A1,g_B1,g_C1) do p.isFrozen = true

    -- normalize 安全版
    fn safeNormalize v =
    (
        local L = length v
        if L<1e-4 then [1,0,0] else v/L
    )

    -- 親→子 縦距離を g_dist にクランプ
    fn clampToParent child parent =
    (
        child.pos = parent.pos + safeNormalize(child.pos-parent.pos)*g_dist
    )

    -- すべての距離制約を維持するメイン関数
    fn maintainAllConstraints mover =
    (
        if not g_busy then 
        g_busy = true
        try
        (
            -- 1) まず縦距離を固定
            clampToParent g_A2 g_A1
            clampToParent g_B2 g_B1
            clampToParent g_C2 g_C1

            -- 2) mover に応じて横方向を連鎖補正
            case mover of
            (
                g_A2: -- A2 を動かしたら → B2→C2
                (
                    -- B2 を A2 から g_dist 離れた位置に
                    g_B2.pos = g_A2.pos + safeNormalize(g_B2.pos-g_A2.pos)*g_dist
                    clampToParent g_B2 g_B1

                    -- C2 を B2 から g_dist 離れた位置に
                    g_C2.pos = g_B2.pos + safeNormalize(g_C2.pos-g_B2.pos)*g_dist
                    clampToParent g_C2 g_C1
                )

                g_B2: -- B2 を動かしたら → A2 と C2
                (
                    -- A2 を B2 から g_dist 離れた位置に
                    g_A2.pos = g_B2.pos + safeNormalize(g_A2.pos-g_B2.pos)*g_dist
                    clampToParent g_A2 g_A1

                    -- C2 を B2 から g_dist 離れた位置に
                    g_C2.pos = g_B2.pos + safeNormalize(g_C2.pos-g_B2.pos)*g_dist
                    clampToParent g_C2 g_C1
                )

                g_C2: -- C2 を動かしたら → B2→A2
                (
                    -- B2 を C2 から g_dist 離れた位置に
                    g_B2.pos = g_C2.pos + safeNormalize(g_B2.pos-g_C2.pos)*g_dist
                    clampToParent g_B2 g_B1

                    -- A2 を B2 から g_dist 離れた位置に
                    g_A2.pos = g_B2.pos + safeNormalize(g_A2.pos-g_B2.pos)*g_dist
                    clampToParent g_A2 g_A1
                )
            )
        )
        catch
        (
            format "Error in maintainAllConstraints: %\n" (getCurrentException())
        )
        finally
        (
            g_busy = false
        )
    )

    -- ハンドラ登録
    deleteAllChangeHandlers id:#DistAll
    when transform g_A2 changes id:#DistAll do maintainAllConstraints g_A2
    when transform g_B2 changes id:#DistAll do maintainAllConstraints g_B2
    when transform g_C2 changes id:#DistAll do maintainAllConstraints g_C2

    format "Setup complete: 縦横すべて g_dist で固定、C2 の移動で B2→A2 も連動します。\n"
)
このMAXSCRIPTの問題点を指摘して