Example Plug-in Package

This example will walk through creating and packaging a simple MAXScript-based plug-in that has assorted assets configured as components in the PackageContents.xml file, using the Autodesk Application Plug-in Package format.

Consider this simple MAXScript macroScript, called new_menu_demo.ms, that creates a menu item with an icon:

-- create a menu w/ an icon
macroScript demo_icon_menu category: "mxs docs" tooltip:"Demo Icon Menu"
IconName:"test1"
(
    helloWorld ("MAXScript Menu")
)

-- This contextID is randomly generated with genClassID(), 
-- don't use this one in your own code
-- See the docs for menuMan.registerMenuContext for more info
if menuMan.registerMenuContext 0x93166fc then (
    mainMenu = menuMan.getMainMenuBar()
    myTestMenu = menuMan.createMenu "Demo Menu"
    myTestMenuItem = menuMan.createSubMenuItem "Demo Menu" myTestMenu
    mainMenu.addItem myTestMenuItem -1
    myAction = menuMan.createActionItem "demo_icon_menu" "mxs docs"
    myTestMenu.addItem myAction (myTestMenu.numItems()+1)
    menuMan.updateMenuBar()
)

We can create a the PackageContents.xml file for the above macro script that looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <ApplicationPackage 
        SchemaVersion="1.0" 
        AutodeskProduct="3ds Max" 
        ProductType="Application" 
        Name="My 3ds Max Plugin"
        AppVersion="1.0.0"
        ProductCode="{caedfa12-cf58-4188-a22b-e4cf2e52baa2}" 
        UpgradeCode="{68b04f36-d00b-436e-9386-7337afcffa4a}">
        <CompanyDetails />
        <Components Description="post-start-up scripts parts">
            <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2018" SeriesMax="2020" />
            <ComponentEntry AppName="DemoMenu" Version="1.0.0" ModuleName="./post_startup_scripts/new_menu_demo.ms" />
        </Components>
    </ApplicationPackage>

Here we specify a single component, a "post-start-up script". Note that there are two types of start-up script parts. In this case, we run post start up, after the UI system has initialized, because we need to have menus present.

Create the following folder and file structure for testing: C:\Test\NewMenuDemo\PackageContents.xml C:\Test\NewMenuDemo\post_startup_scripts\new_menu_demo.ms Set the ADSK_APPLICATION_PLUGINS environment variable to C:\Test\

Launch 3ds Max to confirm that the script loads properly.

To add the icon used by the plug-in, we need to set additional paths for 3ds Max to search for icons in. A plug-in should set both light and dark theme paths, even if the icons are the same for both themes. Our script is looking for a multi-resolution icon named "test1", so we will create an icon directory inside the package directory for each theme, and put the icons in them.
C:\Test\NewMenuDemo\icons\dark\test1.ico C:\Test\NewMenuDemo\icons\light\test1.ico

We then add these components to the PackageContents.xml:

    <Components Description="light icon paths parts">
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2018" SeriesMax="2020" />
        <ComponentEntry AppName="lighticons" Version="1.0.0" ModuleName="./icons/Light" />
    </Components>
    <Components Description="dark icon paths parts">
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2018" SeriesMax="2020" />
        <ComponentEntry AppName="darkicons" Version="1.0.0" ModuleName="./icons/Dark" />
    </Components>

Adding more components involves adding the item to the package directory, and then adding a component entry to the PackageContents.xml file. For example, we can add another MAXScript called by our menu, called mxs_function.ms:

fn helloWorld msg = (
    format "Hello world %\n" msg
)

Because there is no dependency on a UI in this script, we can add it to the pre-start-up scripts:

    <Components Description="pre-start-up scripts parts">
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2018" SeriesMax="2020" />
        <ComponentEntry AppName="DemoMenu" Version="1.0.0" ModuleName="./pre_startup_scripts/mxs_function.ms" />
    </Components>

Once you have tested that the package loads from the test folder, you can create a zip archive for upload to the Autodesk App Store, or add it to an installer for distribution to 3ds Max users, and install to one of the locations described in the Packaging Plug-ins topic.

OSL and AMG Shaders Example

This example shows how to package OSL shaders:

    <?xml version="1.0" encoding="utf-8"?> 
    <ApplicationPackage SchemaVersion="1.0" AutodeskProduct="3ds Max" Name="OSL and AMG Shaders" Description="OSL and AMG Plugin Package Example" AppVersion="1.0.0"    ProductType="Application" AppNameSpace="appstore.exchange.autodesk.com" Author="Autodesk" ProductCode="{89013b63-a8b6-4e83-81c0-9cc1ecbb308e}" UpgradeCode="{4f6e7e7c-ad40-4093-8063-4be9f1b78eb4}"> 
    <CompanyDetails Name="Autodesk Productions" Url="http://www.autodesk.com" /> 
    <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2021" SeriesMax="2021" /> 
    <Components Description="osl folders parts"> 
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2021" SeriesMax="2021" /> 
        <ComponentEntry ModuleName="./Contents/OSL/" /> 
    </Components> 
    <Components Description="amg folders parts"> 
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2021" SeriesMax="2021" /> 
        <ComponentEntry ModuleName="./Contents/AMG/" /> 
    </Components> 
    <Components Description="hotkey parts"> 
        <RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2023" SeriesMax="2023" /> 
        <ComponentEntry ModuleName="./Contents/Hotkeys/SnapPivotHotkeys.hsx" /> 
    </Components> 
    </ApplicationPackage>