Archive site for Autodesk Ecotect Analysis educational resources, notes and tutorials



SpiralStair

Creates a Spiraled Staircase based on user defined inputs of total stair Height, StepHeight, width of bottom Tread, width of top tread, number of revolutions, and rail height

Script Contents (Lang: lua)

cmd("wizard.load Spiral.wzd")

-- Add interactive wizard functions here...




set("wizard.Page1.SpiralButton.OnClick SpiralFunction")

function SpiralFunction(pageName, itemName)
    -- Enter callback action here.
    set("wizard.Page2.Visible", true)
    set("wizard.Page2.Active", true)

end

SpiralFunction()

        cmd("wizard.show")
        cmd("app.activate")
        add("zone", "SpiralZone")

        -- Convertion from M to mm
        function mm(v)
          return v * 1000
        end

    -- Store wizard values as local variables.
    TotalHeight = tonumber (mm(get("wizard.Page2.EditTotalHeight.Text")))
    StepHeight = tonumber (mm(get("wizard.Page2.EditStepHeight.Text")))
    StartRadius = tonumber (mm(get("wizard.Page2.EditStartRadius.Text")))
    EndRadius = tonumber (mm(get("wizard.Page2.EditEndRadius.Text")))
    RailHeight = tonumber (mm(get("wizard.Page2.EditRailHeight.Text")))
    Revolutions = tonumber (get("wizard.Page2.EditRevolutions.Text"))
    centreX = tonumber(mm(get("wizard.Page2.EditX.Text")))
    centreY = tonumber(mm(get("wizard.Page2.EditY.Text")))
    centreZ = tonumber(mm(get("wizard.Page2.EditZ.Text")))

    segments = TotalHeight/StepHeight
    RadiusSteps = (StartRadius - EndRadius) / segments

    if segments > 2 then
                angle = ((360*Revolutions) / segments);
        else
                angle = 90
        end

    radius = StartRadius
    nodeCount = 0

    -- Clear the current selection set.
    cmd("select.none");

    -- Create new object.
    o = add("object", "line", "", true);

    -- Check for a valid object index.
    if o > -1 then

       for t = 0, (360*Revolutions), angle do

          x = centreX + (sin(t) * radius);
          y = centreY + (cos(t) * radius);
          add("node", o, nodeCount, x, y, centreZ)
          nodeCount = nodeCount + 1
          centreZ = centreZ + StepHeight
          radius = radius - RadiusSteps
        end

       set("object.done")
       -- Complete the object so ECOTECT
       -- knows to calc equation & normal.
       cmd("object.extrude", o, 0, 0, RailHeight)

    end

    x, y, z = get("object.node.position", o, NodeNum)
    cmd("view.redraw")
    for NodeNum = 0,nodeCount - 2,1 do

           LINindex = add("object", "ceiling", "plane")
           NodeAindex = add("node", LINindex, 0, x, y, z + StepHeight)
           NodeBindex = add("node", LINindex, 1,centreX,centreY, z +StepHeight)
           x, y, z = get("object.node.position", o, NodeNum+1)
           NodeCindex = add("node", LINindex, 2, x, y, z)
           cmd("object.done")
    end

cmd("view.fitgrid")
cmd("view.fit")
cmd("view.redraw")

AttachmentSize
sPIRAL.zip86.69 KB

HOW WOULD YOU RATE THIS SCRIPT ?

No votes yet


Navigation

User login

Translate Site To: