[Closed] what is wrong in this maxscript ?
in this script something is wrong … Help me pls !!!
fn ReadExcelData excelFile =
(
local filenames = #()
local xl = CreateOLEObject “Excel.Application”
xl.Workbooks.Open excelFile
-- get the Workbook. Workbook apparently is the open file.
if xl.Workbooks.count > 0 do -- number of open
files.
(
thisWorkbook = xl.Workbooks 1
-- get the Worksheet. The "tab" of the spreadsheet.
thisWorksheet = thisWorkbook.Worksheets 1
totalRows = thisWorksheet.usedRange.rows.count
for i = 3 to totalRows do
(
if (thisWorksheet.cells i 3).value != undefined do
(
animName = (thisWorksheet.cells i 2).value
if animName != undefined do append filenames animName
)
)
)
-- Shut it all down
xl.quit()
releaseOLEObject xl
releaseAllOLEObjects() -- probably optional, but
who knows?
sort filenames
)
Ths script is made by Dave “Stokes” Stokes
Technical Artist
Blue Fang Games
10 Q
Reply
You should really explain what exactly you’re trying to do here, and what’s going wrong including any exceptions or unexpected results. This is nearly as bad as posting a thread titled “Help me please” in the main max forum.
On first glance it would appear that you’re trying to get a list of animation names from a spreadsheet and store them in a local array, which is eventually sorted. The problem you may be having is that you’re not actually returning anything. You pass the fn() an excel file, it gets the names and sorts them in an array, but then it doesn’t return the sorted array to you for further use, which is what I would expect it to do. Give us some more details and we should be able to troubleshoot it pretty quickly.
edit: If I hit the nail on the head here, try adding a
return filenames
after your sort operation