またスクリプトが壊れてしまった
(
    delete objects

    global g_dist = 20.0
    global g_z = 10.0
    global g_size = 8.0
    global g_busy = false

    /* ---------- ヘルパー生成（D3まで拡張） ---------- */
    -- 第1列（固定）
    global g_A1 = point name:"A1" pos:[0, g_dist*3, g_z] size:g_size wirecolor:red cross:true
    global g_B1 = point name:"B1" pos:[0, g_dist*2, 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_D1 = point name:"D1" pos:[0, 0, g_z] size:g_size wirecolor:yellow cross:true

    -- 第2列
    global g_A2 = point name:"A2" pos:[g_dist, g_dist*3, g_z] size:g_size wirecolor:orange cross:true
    global g_B2 = point name:"B2" pos:[g_dist, g_dist*2, 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
    global g_D2 = point name:"D2" pos:[g_dist, 0, g_z] size:g_size wirecolor:(color 255 0 255) cross:true

    -- 第3列
    global g_A3 = point name:"A3" pos:[g_dist*2, g_dist*3, g_z] size:g_size wirecolor:yellow cross:true
    global g_B3 = point name:"B3" pos:[g_dist*2, g_dist*2, g_z] size:g_size wirecolor:yellow cross:true
    global g_C3 = point name:"C3" pos:[g_dist*2, g_dist, g_z] size:g_size wirecolor:yellow cross:true
    global g_D3 = point name:"D3" pos:[g_dist*2, 0, g_z] size:g_size wirecolor:yellow cross:true

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

    /* ---------- ユーティリティ関数 ---------- */
    fn safeNormalize v =
    (
        local L = length v
        if L < 1e-4 then [1,0,0] else v/L
    )

    /* ---------- 平行四辺形維持（Z軸固定） ---------- */
    fn maintainParallelogram mover =
    (
        if g_busy then return()
        g_busy = true

        try
        (
            local baseVec, parent, dirVec
            case mover of
            (
                g_A2: (parent = g_A1; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_B2: (parent = g_B1; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_C2: (parent = g_C1; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_D2: (parent = g_D1; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_A3: (parent = g_A2; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_B3: (parent = g_B2; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_C3: (parent = g_C2; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
                g_D3: (parent = g_D2; baseVec = [mover.pos.x - parent.pos.x, mover.pos.y - parent.pos.y, 0])
            )

            if parent != undefined do
            (
                dirVec = safeNormalize(baseVec) * g_dist

                -- 各ポイントに応じた処理
                case mover of
                (
                    g_A2:
                    (
                        g_A2.pos = [g_A1.pos.x + dirVec.x, g_A1.pos.y + dirVec.y, g_A2.pos.z]
                        g_B2.pos = [g_B1.pos.x + dirVec.x, g_B1.pos.y + dirVec.y, g_B2.pos.z]
                        g_C2.pos = [g_C1.pos.x + dirVec.x, g_C1.pos.y + dirVec.y, g_C2.pos.z]
                        g_D2.pos = [g_D1.pos.x + dirVec.x, g_D1.pos.y + dirVec.y, g_D2.pos.z]

                        g_A3.pos = [g_A2.pos.x + (g_A3.pos.x - g_A2.pos.x), g_A2.pos.y + (g_A3.pos.y - g_A2.pos.y), g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + (g_B3.pos.x - g_B2.pos.x), g_B2.pos.y + (g_B3.pos.y - g_B2.pos.y), g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + (g_C3.pos.x - g_C2.pos.x), g_C2.pos.y + (g_C3.pos.y - g_C2.pos.y), g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + (g_D3.pos.x - g_D2.pos.x), g_D2.pos.y + (g_D3.pos.y - g_D2.pos.y), g_D3.pos.z]
                    )

                    g_B2:
                    (
                        g_A2.pos = [g_A1.pos.x + dirVec.x, g_A1.pos.y + dirVec.y, g_A2.pos.z]
                        g_B2.pos = [g_B1.pos.x + dirVec.x, g_B1.pos.y + dirVec.y, g_B2.pos.z]
                        g_C2.pos = [g_C1.pos.x + dirVec.x, g_C1.pos.y + dirVec.y, g_C2.pos.z]
                        g_D2.pos = [g_D1.pos.x + dirVec.x, g_D1.pos.y + dirVec.y, g_D2.pos.z]

                        g_A3.pos = [g_A2.pos.x + (g_A3.pos.x - g_A2.pos.x), g_A2.pos.y + (g_A3.pos.y - g_A2.pos.y), g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + (g_B3.pos.x - g_B2.pos.x), g_B2.pos.y + (g_B3.pos.y - g_B2.pos.y), g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + (g_C3.pos.x - g_C2.pos.x), g_C2.pos.y + (g_C3.pos.y - g_C2.pos.y), g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + (g_D3.pos.x - g_D2.pos.x), g_D2.pos.y + (g_D3.pos.y - g_D2.pos.y), g_D3.pos.z]
                    )

                    g_C2:
                    (
                        g_A2.pos = [g_A1.pos.x + dirVec.x, g_A1.pos.y + dirVec.y, g_A2.pos.z]
                        g_B2.pos = [g_B1.pos.x + dirVec.x, g_B1.pos.y + dirVec.y, g_B2.pos.z]
                        g_C2.pos = [g_C1.pos.x + dirVec.x, g_C1.pos.y + dirVec.y, g_C2.pos.z]
                        g_D2.pos = [g_D1.pos.x + dirVec.x, g_D1.pos.y + dirVec.y, g_D2.pos.z]

                        g_A3.pos = [g_A2.pos.x + (g_A3.pos.x - g_A2.pos.x), g_A2.pos.y + (g_A3.pos.y - g_A2.pos.y), g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + (g_B3.pos.x - g_B2.pos.x), g_B2.pos.y + (g_B3.pos.y - g_B2.pos.y), g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + (g_C3.pos.x - g_C2.pos.x), g_C2.pos.y + (g_C3.pos.y - g_C2.pos.y), g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + (g_D3.pos.x - g_D2.pos.x), g_D2.pos.y + (g_D3.pos.y - g_D2.pos.y), g_D3.pos.z]
                    )

                    g_D2:
                    (
                        g_A2.pos = [g_A1.pos.x + dirVec.x, g_A1.pos.y + dirVec.y, g_A2.pos.z]
                        g_B2.pos = [g_B1.pos.x + dirVec.x, g_B1.pos.y + dirVec.y, g_B2.pos.z]
                        g_C2.pos = [g_C1.pos.x + dirVec.x, g_C1.pos.y + dirVec.y, g_C2.pos.z]
                        g_D2.pos = [g_D1.pos.x + dirVec.x, g_D1.pos.y + dirVec.y, g_D2.pos.z]

                        g_A3.pos = [g_A2.pos.x + (g_A3.pos.x - g_A2.pos.x), g_A2.pos.y + (g_A3.pos.y - g_A2.pos.y), g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + (g_B3.pos.x - g_B2.pos.x), g_B2.pos.y + (g_B3.pos.y - g_B2.pos.y), g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + (g_C3.pos.x - g_C2.pos.x), g_C2.pos.y + (g_C3.pos.y - g_C2.pos.y), g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + (g_D3.pos.x - g_D2.pos.x), g_D2.pos.y + (g_D3.pos.y - g_D2.pos.y), g_D3.pos.z]
                    )

                    g_A3:
                    (
                        g_A3.pos = [g_A2.pos.x + dirVec.x, g_A2.pos.y + dirVec.y, g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + dirVec.x, g_B2.pos.y + dirVec.y, g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + dirVec.x, g_C2.pos.y + dirVec.y, g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + dirVec.x, g_D2.pos.y + dirVec.y, g_D3.pos.z]
                    )

                    g_B3:
                    (
                        g_A3.pos = [g_A2.pos.x + dirVec.x, g_A2.pos.y + dirVec.y, g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + dirVec.x, g_B2.pos.y + dirVec.y, g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + dirVec.x, g_C2.pos.y + dirVec.y, g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + dirVec.x, g_D2.pos.y + dirVec.y, g_D3.pos.z]
                    )

                    g_C3:
                    (
                        g_A3.pos = [g_A2.pos.x + dirVec.x, g_A2.pos.y + dirVec.y, g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + dirVec.x, g_B2.pos.y + dirVec.y, g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + dirVec.x, g_C2.pos.y + dirVec.y, g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + dirVec.x, g_D2.pos.y + dirVec.y, g_D3.pos.z]
                    )

                    g_D3:
                    (
                        g_A3.pos = [g_A2.pos.x + dirVec.x, g_A2.pos.y + dirVec.y, g_A3.pos.z]
                        g_B3.pos = [g_B2.pos.x + dirVec.x, g_B2.pos.y + dirVec.y, g_B3.pos.z]
                        g_C3.pos = [g_C2.pos.x + dirVec.x, g_C2.pos.y + dirVec.y, g_C3.pos.z]
                        g_D3.pos = [g_D2.pos.x + dirVec.x, g_D2.pos.y + dirVec.y, g_D3.pos.z]
                    )
                )
            )
        )
        catch
        (
            format "Error in maintainParallelogram: %\n" (getCurrentException())
        )
        finally
        (
            g_busy = false
        )
    )

    /* ---------- 親からの距離をg_distに固定 ---------- */
    fn clampToParent child parent =
    (
        child.pos = parent.pos + safeNormalize(child.pos - parent.pos) * g_dist
    )

    /* ---------- 距離制約（完全版：全方向連鎖対応） ---------- */
    fn maintainOriginalConstraints mover =
    (
        if g_busy then return()
        g_busy = true

        try
        (
            /* --- 1. 逆伝播 (IK) + 特殊な連鎖処理 --- */
            case mover of
            (
                g_A3:
                (
                    g_A2.pos = g_A1.pos + safeNormalize(g_A3.pos - g_A1.pos) * g_dist
                    g_A3.pos = g_A2.pos + safeNormalize(g_A3.pos - g_A2.pos) * g_dist
                )
                g_B3:
                (
                    g_B2.pos = g_B1.pos + safeNormalize(g_B3.pos - g_B1.pos) * g_dist
                    g_B3.pos = g_B2.pos + safeNormalize(g_B3.pos - g_B2.pos) * g_dist
                )
                g_C3:
                (
                    g_C2.pos = g_C1.pos + safeNormalize(g_C3.pos - g_C1.pos) * g_dist
                    g_C3.pos = g_C2.pos + safeNormalize(g_C3.pos - g_C2.pos) * g_dist
                )
                g_D3:
                (
                    g_D2.pos = g_D1.pos + safeNormalize(g_D3.pos - g_D1.pos) * g_dist
                    g_D3.pos = g_D2.pos + safeNormalize(g_D3.pos - g_D2.pos) * g_dist

                    local dirDC = safeNormalize(g_C2.pos - g_D2.pos)
                    g_C2.pos = g_D2.pos + dirDC * g_dist; clampToParent g_C2 g_C1

                    local dirCB = safeNormalize(g_B2.pos - g_C2.pos)
                    g_B2.pos = g_C2.pos + dirCB * g_dist; clampToParent g_B2 g_B1

                    local dirBA = safeNormalize(g_A2.pos - g_B2.pos)
                    g_A2.pos = g_B2.pos + dirBA * g_dist; clampToParent g_A2 g_A1

                    local dirDC3 = safeNormalize(g_C3.pos - g_D3.pos)
                    g_C3.pos = g_D3.pos + dirDC3 * g_dist; clampToParent g_C3 g_C2

                    local dirCB3 = safeNormalize(g_B3.pos - g_C3.pos)
                    g_B3.pos = g_C3.pos + dirCB3 * g_dist; clampToParent g_B3 g_B2

                    local dirBA3 = safeNormalize(g_A3.pos - g_B3.pos)
                    g_A3.pos = g_B3.pos + dirBA3 * g_dist; clampToParent g_A3 g_A2
                )
                g_D2:
                (
                    local dirDC = safeNormalize(g_C2.pos - g_D2.pos)
                    g_C2.pos = g_D2.pos + dirDC * g_dist; clampToParent g_C2 g_C1

                    local dirCB = safeNormalize(g_B2.pos - g_C2.pos)
                    g_B2.pos = g_C2.pos + dirCB * g_dist; clampToParent g_B2 g_B1

                    local dirBA = safeNormalize(g_A2.pos - g_B2.pos)
                    g_A2.pos = g_B2.pos + dirBA * g_dist; clampToParent g_A2 g_A1

                    local dirA3 = safeNormalize(g_A3.pos - g_A2.pos)
                    g_A3.pos = g_A2.pos + dirA3 * g_dist; clampToParent g_A3 g_A2

                    local dirB3 = safeNormalize(g_B3.pos - g_B2.pos)
                    g_B3.pos = g_B2.pos + dirB3 * g_dist; clampToParent g_B3 g_B2

                    local dirC3 = safeNormalize(g_C3.pos - g_C2.pos)
                    g_C3.pos = g_C2.pos + dirC3 * g_dist; clampToParent g_C3 g_C2
                )
                g_C2:
                (
                    local dirCB = safeNormalize(g_B2.pos - g_C2.pos)
                    g_B2.pos = g_C2.pos + dirCB * g_dist; clampToParent g_B2 g_B1

                    local dirBA = safeNormalize(g_A2.pos - g_B2.pos)
                    g_A2.pos = g_B2.pos + dirBA * g_dist; clampToParent g_A2 g_A1

                    local dirA3 = safeNormalize(g_A3.pos - g_A2.pos)
                    g_A3.pos = g_A2.pos + dirA3 * g_dist; clampToParent g_A3 g_A2

                    local dirB3 = safeNormalize(g_B3.pos - g_B2.pos)
                    g_B3.pos = g_B2.pos + dirB3 * g_dist; clampToParent g_B3 g_B2

                    local dirC3 = safeNormalize(g_C3.pos - g_C2.pos)
                    g_C3.pos = g_C2.pos + dirC3 * g_dist; clampToParent g_C3 g_C2
                )
                g_B2:
                (
                    local dirBA = safeNormalize(g_A2.pos - g_B2.pos)
                    g_A2.pos = g_B2.pos + dirBA * g_dist; clampToParent g_A2 g_A1

                    local dirBC = safeNormalize(g_C2.pos - g_B2.pos)
                    g_C2.pos = g_B2.pos + dirBC * g_dist; clampToParent g_C2 g_C1

                    local dirA3 = safeNormalize(g_A3.pos - g_A2.pos)
                    g_A3.pos = g_A2.pos + dirA3 * g_dist; clampToParent g_A3 g_A2

                    local dirB3 = safeNormalize(g_B3.pos - g_B2.pos)
                    g_B3.pos = g_B2.pos + dirB3 * g_dist; clampToParent g_B3 g_B2

                    local dirC3 = safeNormalize(g_C3.pos - g_C2.pos)
                    g_C3.pos = g_C2.pos + dirC3 * g_dist; clampToParent g_C3 g_C2
                )
                g_A2:
                (
                    local dirAB = safeNormalize(g_B2.pos - g_A2.pos)
                    g_B2.pos = g_A2.pos + dirAB * g_dist; clampToParent g_B2 g_B1

                    local dirBC = safeNormalize(g_C2.pos - g_B2.pos)
                    g_C2.pos = g_B2.pos + dirBC * g_dist; clampToParent g_C2 g_C1

                    local dirA3 = safeNormalize(g_A3.pos - g_A2.pos)
                    g_A3.pos = g_A2.pos + dirA3 * g_dist; clampToParent g_A3 g_A2

                    local dirB3 = safeNormalize(g_B3.pos - g_B2.pos)
                    g_B3.pos = g_B2.pos + dirB3 * g_dist; clampToParent g_B3 g_B2

                    local dirC3 = safeNormalize(g_C3.pos - g_C2.pos)
                    g_C3.pos = g_C2.pos + dirC3 * g_dist; clampToParent g_C3 g_C2
                )
            )

            /* --- 2. 縦方向の距離制約（基本） --- */
            clampToParent g_A2 g_A1
            clampToParent g_B2 g_B1
            clampToParent g_C2 g_C1
            clampToParent g_D2 g_D1

            /* --- 3. 横方向の連鎖補正（第2列：A2→B2→C2→D2） --- */
            local dirAB = safeNormalize(g_B2.pos - g_A2.pos) * g_dist
            g_B2.pos = g_A2.pos + dirAB; clampToParent g_B2 g_B1

            local dirBC = safeNormalize(g_C2.pos - g_B2.pos) * g_dist
            g_C2.pos = g_B2.pos + dirBC; clampToParent g_C2 g_C1

            local dirCD = safeNormalize(g_D2.pos - g_C2.pos) * g_dist
            g_D2.pos = g_C2.pos + dirCD; clampToParent g_D2 g_D1

            /* --- 4. 縦方向の距離制約（第3列） --- */
            clampToParent g_A3 g_A2
            clampToParent g_B3 g_B2
            clampToParent g_C3 g_C2
            clampToParent g_D3 g_D2

            /* --- 5. 横方向の連鎖補正（第3列：A3→B3→C3→D3） --- */
            local dirA3B3 = safeNormalize(g_B3.pos - g_A3.pos) * g_dist
            g_B3.pos = g_A3.pos + dirA3B3; clampToParent g_B3 g_B2

            local dirB3C3 = safeNormalize(g_C3.pos - g_B3.pos) * g_dist
            g_C3.pos = g_B3.pos + dirB3C3; clampToParent g_C3 g_C2

            local dirC3D3 = safeNormalize(g_D3.pos - g_C3.pos) * g_dist
            g_D3.pos = g_C3.pos + dirC3D3; clampToParent g_D3 g_D2
        )
        catch
        (
            format "Error in maintainOriginalConstraints: %\n" (getCurrentException())
        )
        finally
        (
            g_busy = false
        )
    )

    /* ---------- 統合制御 ---------- */
    fn maintainAllConstraints mover =
    (
        maintainParallelogram mover
        maintainOriginalConstraints mover
    )

    /* ---------- ハンドラ登録 ---------- */
    deleteAllChangeHandlers id:#CombinedConstraints
    when transform g_A2 changes id:#CombinedConstraints do maintainAllConstraints g_A2
    when transform g_B2 changes id:#CombinedConstraints do maintainAllConstraints g_B2
    when transform g_C2 changes id:#CombinedConstraints do maintainAllConstraints g_C2
    when transform g_D2 changes id:#CombinedConstraints do maintainAllConstraints g_D2
    when transform g_A3 changes id:#CombinedConstraints do maintainAllConstraints g_A3
    when transform g_B3 changes id:#CombinedConstraints do maintainAllConstraints g_B3
    when transform g_C3 changes id:#CombinedConstraints do maintainAllConstraints g_C3
    when transform g_D3 changes id:#CombinedConstraints do maintainAllConstraints g_D3

    format "Setup complete: 全方向連鎖完全版\n"
)
この平行四辺形を維持するシステムを維持しながらD4まで拡張して