ScriptSpot

Forum topic · General Scripting

Macrotize - help please

By W DIGITAL · 2009-05-04

Description

hi, i have a problem, anubis created this code for me, it creates a macro file for each script you have in /scripts/test/ folder, so that you can add each script to the toolbar, not having to add every script manually!

*************************************************************

files = getFiles ((getDir #scripts) + "\\test\\*.ms")
if files.count != 0 then
(
for f = 1 to files.count do
templist[f] = getFilenameFile files[f]
for f in files do fname = FilenameFromPath f
)

outputName = getSaveFileName caption:"Save MaxScript File" \
types:"Script Files (*.mcr)|*.mcr|All Files (*.*)|*.*|"
if outputName != undefined then
(
outputFile = CreateFile outputName
for f = 1 to files.count do
(
str = "macroScript new" + (f as string) + " "
str += "category:\"phizikl_test\" tooltip:\""
str += templist[f] + "\" buttonText:\"" + templist[f] + "\"\n"
str += "(\n" + "setCommandPanelTaskMode #create\n"
str += "on execute do\n" + "(\n"
str += "filein \"" + files[f] + "\"\n" + ")\n" + ")\n"
format "%" str to:outputFile
)
close outputFile
)
edit outputName

****************************

can you try it out if it works, because it creates a .mcr file for me, but it is empty, anubis says it works for him, i dont know what the problem is...

thanks for your help!

Comments (4)

W DIGITAL · 2009-05-05

ok thanks,
but does it macrofiy them so i can use them in my toolbar?
thats the main goal im trying to achieve, get my scripts into toolbar!

thanks for your help!

colinsenner · 2009-05-04

It does exactly what you want, check the scripts/test directories for .ms files and loads them at startup. I saved that script to a file called "myscripts.ms" and put them in the C:\Program Files\Autodesk\3dsMax 2009\stdplugs\stdscripts\ folder and now everytime I load max, it'll check the /test directory for script updates. I use a network directory to distribute my scripts to all my coworkers so I can update them easily and transparently.

W DIGITAL · 2009-05-04

what exactly does it do??? :)
sorry im not a programmer ^_°

colinsenner · 2009-05-04

I use this one for my scripts



global directoryToLook = scriptsPath + "/test"
global getDirsRecursive
global doesDirectoryExist

--- Functions ---
fn getDirsRecursive root = (
    if root != "" then (
        dir_array = GetDirectories (root+"/*")
   
        for d in dir_array do
            join dir_array (GetDirectories (d+"/*"))
       
        append dir_array root
        return dir_array
    )
    return undefined
)

fn doesDirectoryExist dir = if (getFiles (dir+"/*")).count != 0 then true else false

-- Running Code
(
    if doesDirectoryExist directoryToLook then (
        local dirArr = getDirsRecursive directoryToLook
        local fileArr = #()
   
        for d in dirArr do
            join fileArr (getFiles (d+"/*.*"))
   
        for f in fileArr do
            try ( fileIn f ) catch ( format "Scripts - Cannot load %.\n" f )

        format "Scripts Updated and Loaded... (%)\n" (fileArr.count as string)
    ) else
        format "Scripts Scripts - Can't find %!\n" directoryToLook
)

This'll also get subdirectories of /test/ if you want that too.