data = AskUser("Selector", { {"name", Name = "USERNAME", "Text", Default = username, Lines = 1}, {"fill01", Name = "", "Position", Default = {1, 0.5}, Width = 1.5}, {"project", Name = "Select project", "Dropdown", Options = ndirs, Default = 0}, })
if data == nil then return end
-- if didnt entered name
if data["name"] == "" or data["name"] == " " or data["name"] == " " or data["name"] == " " then no_name = AskUser("Error", { {"info", Name = "No Name", "Text", Lines = 2, Width = 1.5, ReadOnly = true, FontName = "Calibri", FontSize = 18, Default = "You did not entered your name,\nRun Script again and Enter name first"},
Here is a Lua native code snippet example that works with Fusion 7 & 8 and lets you scan a folder for its contents on Windows/Mac/Linux. The directory contents are then filtered by filetype.
You can modify the code to wrap it in your own function to replace your legacy readdir based commands if you want.
------------------------------------------------------------------------------ -- Scan a Directory Script for Fusion - 2017-03-22 01.53 PM -- by Andrew Hazelden -- www.andrewhazelden.com -- andrew@andrewhazelden.com ------------------------------------------------------------------------------
-- Folder to scan for content sourceFolder = '/FusionMedia/images/'
-- Find out the current operating system platform. The platform local variable should be set to either 'Windows', 'Mac', or 'Linux'. local platform = '' local osSeparator = '' if string.find(comp:MapPath('Fusion:\\'), 'Program Files', 1) then -- Check if the OS is Windows by searching for the Program Files folder platform = 'Windows' osSeparator = '\\' elseif string.find(comp:MapPath('Fusion:\\'), 'PROGRA~1', 1) then -- Check if the OS is Windows by searching for the Program Files folder platform = 'Windows' osSeparator = '\\' elseif string.find(comp:MapPath('Fusion:\\'), 'Applications', 1) then -- Check if the OS is Mac by searching for the Applications folder platform = 'Mac' osSeparator = '/' else platform = 'Linux' osSeparator = '/' end
-- Create a new LUA table for the files to process filesList = {}
-- Build the OS native scan a directory command string dirCommand = '' if platform == 'Windows' then -- The dir options '/b /ad' lists directories and '/b' lists just files dirCommand = 'dir ' .. sourceFolder .. ' /b' else dirCommand = 'ls -a "' .. sourceFolder .. '"' end
print('[Directory Listing]') -- Search the selected directory for movie content for files in io.popen(dirCommand):lines() do -- List the files -- print(files)
-- Add another file to the filesList table fileNoCase = files.lower(files) if fileNoCase:match('.*%.tif') then table.insert(filesList, files) end end
-- List what's in the table print('[Movie Listing]') dump(filesList)
print('\n')
Mac Studio M2 Ultra / Threadripper 3990X | Fusion Studio 18.6.4 | Kartaverse 6