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



Script example 01

AddMoveZone.scr

This script offers a simple introduction to the process of creating, selecting and manipulating objects in ECOTECT. It creates simple rectangular 8mx5m zone using the add.object command. It includes the 'zone' parameter so that ECOTECT will create a new zone from this object and automatically extrude it to the default zone height.

The script then ensures that only the ground floor plan object is selected and then moves it 6m from it's current position in the Y direction. To adjust the height, again with only the ground floor object selected, it extrudes it 5m in the Z direction. Re-extruding an object in ECOTECT simply adjusts the extrusion vector.

Finally it fits the current view to the extents of all objects in the model (in this case just the zone itself).

Script Contents (Lang: lua)

--[[-----------------------------------------------
-- This script creates a new zone by generating a
-- floor plan and then extruding it.  Note the use
-- of the 'zone' property within the 'add.object' 
-- command to ensure the creation of a new zone.
--]]-----------------------------------------------

-- Bring ECOTECT to the front
-- if it is not already.
cmd("app.activate")

-- Start with a clean slate.
cmd("model.new");

-- Set up a coordinate array.
nodes = 4;
nodeList = {
    { 0.0, 0.0, 0.0},
    { 8000.0, 0.0, 0.0},
    { 8000.0, 5000.0, 0.0},
    { 0.0, 5000.0, 0.0},
    }

-- Attempt to create a new floor object.
-- The 'add' command returns the index number 
-- of the newly created object.  As the zone
-- parameter is given, ECOTECT will automatically
-- extrude the object and make it a new zone.
o = add("object floor zone", true);

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

    -- Add nodes to new object.
    -- NOTE: ECOTECT index numbers are zero-based
    -- whereas LUA arrays start at 1, hence n-1.
    for n = 1,nodes do
        add("node", o, n-1,  
        nodeList[n][1], nodeList[n][2], nodeList[n][3]
        );
    end

    -- Complete the object.
    -- ECOTECT needs to know when you have
    -- finished adding nodes to an object so
    -- that it can calculate its area, plane
    -- equation and so on. It will automatically
    -- do this if your start another object, but
    -- in this case we aren't going to, so we
    -- need to manually tell it we're done.
    set("object.done");

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

    -- Make sure only the newly 
    -- created floor object is selected.
    set("object.selected", o);

    -- Pause for 1 second, for visual effect.
    pause(1000);

    -- Move it to a new location.
    cmd("selection.move", 0.0, 6000.0, 0.0);
    cmd("view.redraw");

    -- Pause again, for visual effect.
    pause(1000);

    -- Extrude it in the Z axis.
    -- Even though the original floor object 
    -- was automatically extruded by the default
    -- zone height, if you re-extrude the floor
    -- it will simply adjust the zone height.
    cmd("selection.extrude", 0.0, 0.0, 5000);
    cmd("view.redraw");

    -- Another pause for visual effect.
    pause(1000);

    -- Fit the current view to the new object.
    cmd("view.fit");

end

HOW WOULD YOU RATE THIS SCRIPT ?

No votes yet


Navigation

User login

Translate Site To: