fn delDir DirPath = (
if doesFileExist dirPath do (
command = "RD /S /Q \""+dirPath+"\""
HiddenDOSCommand command startpath:".\\"
)
)
fn delFile filePath = (
if doesFileExist filePath do (
deleteFile filePath
)
)
fn copyDir sourceDir destDir = (
command = "XCOPY \""+sourceDir+"*\" \""+destDir+"\" /Q /I /S /Y"
HiddenDOSCommand command startpath:".\\"
)
fn uninst = (
if ::OpenAdvancedUVNormalizer !=undefined do (
d=windows.getChildHWND 0 (title1+" v2.4.7")
if d !=undefined do windows.sendMessage d[1] 274 61536 0
)
::OpenAdvancedUVNormalizer=undefined
gc()
sleep 1
delDir (userscripts+title1)
delFile (userstartupscripts+"auvn_autoload.mse")
for i in (getFiles (usermacros+"AUVN*")) do delFile i
)
fn checkuninst = (
if doesFileExist(userscripts+title1) or doesFileExist(userstartupscripts+"auvn_autoload.mse") then (
if qb = queryBox ("You have the "+title1+" installed. Do you want to uninstall it first?") title: "Warning" do uninst()
qb
) else true
)
on auvn_installer open do (
if oldmax do (
lbl1.text="Only 3dsmax 2010+ is supported!"
install1.enabled = false
uninstall.enabled = false
)
)
on install1 pressed do (
if checkuninst() do (
setWaitCursor()
copyDir (tempdir+"scripts\\") userscripts
sleep 1
lbl1.text="Installed successfully."
try filein (userscripts+title1+"\\auvn.mse") Catch(Messagebox "There was an error installing Adv. UV Normalizer" title:"Error")
if queryBox "Installation complete!\n\nGo to Customize -> Customize User Interface, choose \"AUVN\" in the Category list and assign the script wherever you want.\n\nOpen the Customize User Interface dialog now?" title: title1 do actionMan.executeAction 0 "59226"
)
)
on uninstall pressed do (
if queryBox "Are you sure?" title: "Uninstall!" do (
lbl1.text="Started..."
setWaitCursor()
uninst()
lbl1.text="Uninstalled successfully."
)
)
on auvn_installer close do (
if tempdir == symbolicPaths.getPathValue "$temp"+"\\auvn2\\" do delDir tempdir
auvn_installer = undefined
gc()
)
I too have instal.ms file in my ALL3DVRaySceneValidator category:"ALL3D" buttonText:"ALL3D Scene Validator v0.6" toolTip:"V-Ray Scene Validation Tool v0.6 for ALL3D" icon:#("ALL3DVRaySceneValidator", 1) mzp file:
(
filein "$usermacros\ALL3DVRaySceneValidator.mcr"
colorMan.reinitIcons()
messagebox("Install notes:\n\n1. Go to Customize > Customize User Interface and select "Toolbars" Tab.\n\n2. Select "ALL3D" Category.\n\n3. Drag the "ALL3DVRaySceneValidator" to where you want it on toolbar.") title:"ALL3D V-Ray Scene Validator v0.6" icon:#information
)
I want you to create my install.ms file like AUVN_247's installer.ms.
Also, I want it to open Customize User Interface's Toolbar tab, after successful installation of the script.
Certainly! Below is a customized install.ms script for your ALL3DVRaySceneValidator tool, modeled after the AUVN_247.mzp installer script. This script provides a user-friendly installer with options to install and uninstall the tool. After a successful installation, it will automatically open the Customize User Interface dialog's Toolbars tab to help you easily add the tool to your toolbar.
Customized install.ms Script
maxscript
try destroyDialog all3dvrayscenevalidator_installer catch()
rollout all3dvrayscenevalidator_installer "ALL3D V-Ray Scene Validator v0.6 Setup" width:250 height:80
(
local supportedMaxVersion = 24000 -- Example: 24000 corresponds to 2024. Adjust as needed
local currentMaxVersion = maxVersion
local isSupported = currentMaxVersion >= supportedMaxVersion
local userMacrosPath = symbolicPaths.getPathValue "$userMacros" + "\\"
local userScriptsPath = symbolicPaths.getPathValue "$userScripts" + "\\"
local userStartupScriptsPath = symbolicPaths.getPathValue "$userStartupScripts" + "\\"
local tempDir = getFilenamePath (getSourceFileName())
local toolName = "ALL3DVRaySceneValidator"
label lblInfo "Select an option:" pos:[10,10] width:230 height:20 align:#center
button btnInstall "Install" pos:[20,40] width:100 height:30 toolTip:("Install to \"" + userScriptsPath + toolName + "\"")
button btnUninstall "Uninstall" pos:[130,40] width:100 height:30
-- Function to delete a directory recursively
fn delDir dirPath = (
if doesFileExist dirPath do (
local command = "RD /S /Q \"" + dirPath + "\""
HiddenDOSCommand command startpath:.\\
)
)
-- Function to delete a single file
fn delFile filePath = (
if doesFileExist filePath do (
deleteFile filePath
)
)
-- Function to copy directory contents
fn copyDir sourceDir destDir = (
local command = "XCOPY \"" + sourceDir + "*\" \"" + destDir + "\" /Q /I /S /Y"
HiddenDOSCommand command startpath:.\\
)
-- Uninstallation function
fn uninstallTool = (
try (
-- Attempt to close the tool if it's running
if (windows.getChildHWND 0 (toolName + " v0.6")) != undefined do (
windows.sendMessage (windows.getChildHWND 0 (toolName + " v0.6"))[1] 274 61536 0
)
) catch()
-- Remove global reference if any
globals."Open" + toolName = undefined
gc() -- Garbage collect
sleep 1 -- Brief pause to ensure files are not in use
-- Delete installation directories and files
delDir (userScriptsPath + toolName)
delFile (userStartupScriptsPath + "all3dvrayscenevalidator_autoload.mse")
for file in getFiles (userMacrosPath + "ALL3D*") do delFile file
)
-- Function to check if uninstallation is needed
fn checkUninstall = (
if (doesFileExist (userScriptsPath + toolName) or doesFileExist (userStartupScriptsPath + "all3dvrayscenevalidator_autoload.mse")) then (
if (queryBox ("You have " + toolName + " installed. Do you want to uninstall it first?") title:"Warning") do (
uninstallTool()
true
) else (
false
)
) else (
true
)
)
-- Event handler for dialog open
on all3dvrayscenevalidator_installer open do (
if not isSupported then (
lblInfo.text = "Only 3ds Max 2024+ is supported!"
btnInstall.enabled = false
btnUninstall.enabled = false
)
)
-- Event handler for Install button
on btnInstall pressed do (
if checkUninstall() then (
setWaitCursor()
copyDir (tempDir + "scripts\\") userScriptsPath
sleep 1
lblInfo.text = "Installed successfully."
-- Load the installed script
try (
fileIn (userScriptsPath + toolName + "\\all3dvrayscenevalidator.mse")
) catch (
messageBox "There was an error installing ALL3D V-Ray Scene Validator." title:"Error" beep:true
)
-- Prompt the user to customize the UI
if (queryBox "Installation complete!\n\nDo you want to customize the User Interface now?" title:toolName) then (
-- Open the Customize User Interface dialog's Toolbars tab
customizeUI #toolbar
)
clearWaitCursor()
)
)
-- Event handler for Uninstall button
on btnUninstall pressed do (
if (queryBox "Are you sure you want to uninstall ALL3D V-Ray Scene Validator?" title:"Uninstall Confirmation") then (
lblInfo.text = "Uninstalling..."
setWaitCursor()
uninstallTool()
lblInfo.text = "Uninstalled successfully."
clearWaitCursor()
)
)
-- Event handler for dialog close
on all3dvrayscenevalidator_installer close do (
if (tempDir == (symbolicPaths.getPathValue "$temp") + "\\ALL3DVRaySceneValidator\\") then (
delDir tempDir
)
destroyDialog all3dvrayscenevalidator_installer
)
)
createDialog all3dvrayscenevalidator_installer style:#(#style_toolwindow, #style_border, #style_sysmenu)
Explanation of the Script
Dialog Setup:
Rollout Dialog: Creates a dialog titled "ALL3D V-Ray Scene Validator v0.6 Setup" with Install and Uninstall buttons.
Labels and Buttons: Provides user instructions and actionable buttons for installation and uninstallation.
Path Definitions:
symbolicPaths: Utilizes 3ds Max's symbolic paths to determine where to install scripts, macros, and startup scripts.
tempDir: Determines the temporary directory where installation files are located.
Helper Functions:
delDir: Deletes a directory recursively using the RD (Remove Directory) command.
delFile: Deletes a single file if it exists.
copyDir: Copies files from the source directory to the destination using the XCOPY command.
uninstallTool: Handles the uninstallation process, ensuring that any running instances are closed and files are removed.
checkUninstall: Checks if the tool is already installed and prompts the user to uninstall it before proceeding with a fresh installation.
Event Handlers:
on open: Checks if the current version of 3ds Max is supported. If not, it disables the Install and Uninstall buttons and notifies the user.
on btnInstall pressed:
Checks if uninstallation is needed.
Copies the necessary files to the user scripts directory.
Loads the installed script.
Prompts the user to open the Customize User Interface dialog to add the tool to the toolbar.
on btnUninstall pressed: Confirms with the user and proceeds to uninstall the tool if confirmed.
on close: Cleans up any temporary directories and closes the dialog.
Opening Customize User Interface's Toolbars Tab:
After a successful installation, the script uses the customizeUI #toolbar command to open the Customize User Interface dialog directly to the Toolbars tab, allowing the user to easily add the ALL3DVRaySceneValidator to their toolbar.
Instructions to Use the Script
Prepare the Installation Package:
Ensure that your ALL3DVRaySceneValidator scripts are organized in a scripts folder within your .mzp package.
Save the Script:
Save the above script as install.ms within your .mzp package.
Create the .mzp Package:
Include the install.ms script and the scripts folder containing your tool's .mse and .mcr files.
Ensure the directory structure within the .mzp is correct, matching the paths defined in the script.
Installation:
Distribute the .mzp package to users.
Users can install the tool by running the .mzp package, which will execute the install.ms script, guiding them through the installation process.
Post-Installation:
After installation, the Customize User Interface dialog's Toolbars tab will open automatically, making it easy for users to add the ALL3DVRaySceneValidator button to their toolbar.
Notes
3ds Max Version Compatibility:
The supportedMaxVersion variable is set to 24000, which corresponds to 3ds Max 2024. Adjust this value based on the versions you intend to support.
Action Codes:
Instead of using numerical action codes like "59226", the script utilizes the customizeUI function with the #toolbar parameter for clarity and reliability.
Error Handling:
The script includes error handling to notify users if the installation encounters issues.
Feel free to adjust the script to better fit your specific needs or to accommodate additional features. This script provides a solid foundation for a user-friendly installer for your ALL3DVRaySceneValidator tool.