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



Example Script-Generated Wizard

This script creates a wizard entirely within the code, without needing an accompanying WZD file. The aim is to demonstrate how to use some of the interactive features such as hiding and showing other interface elements as well as individual pages.

Script Contents (Lang: lua)

-- --------------------------------------
-- SETUP A SCRIPT-DRIVEN WIZARD.
-- --------------------------------------

set("wizard.Size 600 220")

set("wizard.Page1.Title INTRODUCTION")
set("wizard.Page1.Question WHAT CONFIGURATION DO YOU REQUIRE ?")
set("wizard.Page1.Description This script is intended as an example of how to create a script-driven wizard. Use this text to describe what it does and how it will affect the current model.")
set("wizard.Page1.Description +Add extra paragraphs to the description by simply prefixing the additional text with a + sign. For example:")
set("wizard.Page1.Description +  wizard.Page1.Description +This is...")
set("wizard.Page1.Description +This way you can add any amount of descriptive text.")

add("wizard.Page1.Checkbox HappyFeet1 Hide/Show Other Items")
add("wizard.Page1.Description HappyFeet1 This is an example of assigning an 'onclick' event. Checking this box will hide the other options on the page.")
set("wizard.Page1.HappyFeet1.OnClick HideOptions")

add("wizard.Page1.Checkbox HappyFeet2 Enable/Disable Other Items")
add("wizard.Page1.Description HappyFeet2 This is another example of an 'onclick' event, this time affecting the 'Enabled' property of other options on the page.")
set("wizard.Page1.HappyFeet2.OnClick DisableOptions")

add("wizard.Page1.Checkbox HappyFeet3 Hide/Show Next Wizard Page")
add("wizard.Page1.Description HappyFeet3 This is an example of using an item's selection state to toggle other pages in the wizard. Note that both the STEPS, NEXT >> and OK items update to reflect the change.")
set("wizard.Page1.HappyFeet3.OnClick HidePage2")

add("wizard.page Page2")
set("wizard.Page2.Title MORE QUESTIONS")
set("wizard.Page2.Question WHAT LIST ITEM WOULD YOU LIKE ?")
set("wizard.Page2.Description Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu.")
set("wizard.Page2.Description +Fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") 

add("wizard.Page2.Select DropDownList Option One|Option Two|Option Three|Option Four")
add("wizard.Page2.Description DropDownList This is a simple drop-down list - again built using 'Option'.")
set("wizard.Page2.DropDownList.Index 1")

add("wizard.Page2.Label DropDownTitle Select a Value Here Too:")
set("wizard.Page2.DropDownTitle.Bold true")

add("wizard.Page2.List SelectList")
set("wizard.Page2.SelectList.Offset 0 0 0 -16")
add("wizard.Page2.Description SelectList This is an example of a list item containing multiple items to select from. Use the 'Option' property to add each item.")
set("wizard.Page2.SelectList.Item Option One")
set("wizard.Page2.SelectList.Item Option Two")
set("wizard.Page2.SelectList.Item Option Three")
set("wizard.Page2.SelectList.Item Option Four")
set("wizard.Page2.SelectList.Item Option Five")
set("wizard.Page2.SelectList.Item Option Six")
set("wizard.Page2.SelectList.Index 3")

add("wizard.page Page3")
set("wizard.Page3.Title THE LAST STEP")
set("wizard.Page3.Question ENTER A VALUE HERE:")
set("wizard.Page3.Description Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu.")
set("wizard.Page3.Description +Fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") 

add("wizard.Page3.Edit MyDataEdit 129.84")
add("wizard.Page3.Description MyDataEdit Enter a value here in W/m2.")

add("wizard.Page3.Line Line2")

add("wizard.Page3.Label FileOpenLabel Select File to Open:")
set("wizard.Page3.FileOpenLabel.Bold true")
add("wizard.Page3.File FileOpen")
set("wizard.Page3.FileOpen.OnExit ShowFileName")

set("wizard.Page3.Spacing 4")

add("wizard.Page3.Label FileSaveLabel Select File to Save:")
set("wizard.Page3.FileSaveLabel.Bold true")
add("wizard.Page3.Filesave FileSave")

set("wizard.Page3.Spacing 4")

add("wizard.Page3.Label FolderLabel Select Folder:")
set("wizard.Page3.FolderLabel.Bold true")
add("wizard.Page3.Folder Folder")

set("wizard.Page2.DropDownList.OnClick DropDownListSelected")
set("wizard.Page2.SelectList.OnClick SelectListSelected")

-- --------------------------------------
-- DEFINE ITEM CALLBACK FUNCTIONS.
-- --------------------------------------

function HideOptions()

  state = true
  if get("wizard.Page1.HappyFeet1") > 0 then
    state = false
  end

  set("wizard.Page1.HappyFeet2.Visible", state)
  set("wizard.Page1.HappyFeet2_descr.Visible", state)
  set("wizard.Page1.HappyFeet3.Visible", state)
  set("wizard.Page1.HappyFeet3_descr.Visible", state)

end

function DisableOptions()

  state = true
  if get("wizard.Page1.HappyFeet2") > 0 then
    state = false
  end

  set("wizard.Page1.HappyFeet1.Enabled", state)
  set("wizard.Page1.HappyFeet1_descr.Enabled", state)
  set("wizard.Page1.HappyFeet3.Enabled", state)
  set("wizard.Page1.HappyFeet3_descr.Enabled", state)

end

function HidePage2()

  state = true

  if get("wizard.Page1.HappyFeet3") > 0 then
    state = false
  end

  set("wizard.Page2.Visible", state)

end

function DropDownListSelected()
  selectedItem = get("wizard.Page2.DropDownList.Index")
  set("wizard.Page2.SelectList.Index", selectedItem)
end

function SelectListSelected()
  selectedItem = get("wizard.Page2.SelectList.Index")
  set("wizard.Page2.DropDownList.Index", selectedItem)
end

function ShowFileName()
  string = "You chose file: " .. get("wizard.Page3.FileOpen")
  cmd("app.alert", string)
end

-- --------------------------------------
-- RUN THE SCRIPT.
-- --------------------------------------

cmd("wizard.show Example Script")

-- --------------------------------------
-- POST-PROCESS RESULTS.
-- --------------------------------------

print("PAGE 1 - You selected:")

if get("wizard.Page1.HappyFeet1") > 0 then
  printf("  %s", get("wizard.Page1.HappyFeet1.Caption"))
end

if get("wizard.Page1.HappyFeet2") > 0 then
  printf("  %s", get("wizard.Page1.HappyFeet2.Caption"))
end

if get("wizard.Page1.HappyFeet3") > 0 then
  printf("  %s", get("wizard.Page1.HappyFeet3.Caption"))
end

print("\n")
print("PAGE 2 - You selected:")
index = get("wizard.Page2.SelectList.Index")
option = get("wizard.Page2.SelectList.Option")
printf("  (%d) %s", index, option)
print("And:")
index = get("wizard.Page2.DropDownList.Index")
option = get("wizard.Page2.DropDownList.Option")
printf("  (%d) %s", index, option)

print("\n")
print("PAGE 3 - You Entered:")
printf("  %s", get("wizard.Page3.MyDataEdit.Text"))

HOW WOULD YOU RATE THIS SCRIPT ?

No votes yet


Navigation

User login

Translate Site To: