Adds an item to the add-on. You can use this method only while packaging add-ons. You can use this method to add any of the item types that appear in the File > Add-On > Package dialog (see siAddonItemType for details on the types of items you can add to a package).

C# Syntax

Addon.AddItem( siAddonItemType in_eItemKind, String in_bstrItemName );

Scripting Syntax

Addon.AddItem( in_eItemKind, in_bstrItemName );


Parameter Type Description
in_eItemKind siAddonItemType The type of the item being added.
in_bstrItemName String The name of the item (for example, the name of a command) or the location (the full path including the file name) of the file that contains the item. See siAddonItemType to determine whether you can use the item name or the full path and file name.

Note. This parameter is case-sensitive.


VBScript Example

' **********************************
' This example shows how to add a custom command to an add-on package.
sPath = InstallationPath( siUserPath )
sCmdName = makeCusCmd()
' Create the add-on package object
set oAddOn = Application.CreateAddon
' Add the custom command to the add-on package
oAddOn.AddItem siScriptCmdAddonItemType, sCmdName
' Save the package in the Addons directory
sAddOnFileName = XSIUtils.BuildPath( sPath,  "Addons", "myAddOn.xsiaddon" )
oAddOn.Save sAddOnFileName
' Remove the custom command and install it from the add-on package
if cleanUpCmd( sCmdName ) then
        Application.InstallAddOn sAddOnFileName, siUserAddonPath 
        ' Run it to make sure it works
        set oInstalledCmd = Commands( sCmdName )
        if TypeName( oInstalledCmd ) <> "Nothing" then
                Application.LogMessage "Logged after installing from add-on:"
                ' After we know it works, we can uninstall it
                Application.UnInstallAddon sAddOnFileName 
                Application.LogMessage "Can't find command."
        end if
end if
' **********************************
' Helper functions that take care of 
' creating and removing the command. 
function makeCusCmd()
        ' Start with a clean slate
        Application.RemoveCommand "Howdy"
        ' Build the filename & path
        sCmdFileName = XSIUtils.BuildPath( sPath, "Data", "Scripts", "HelloWorld.vbs" )
        ' Create a "hello world" script file
        set fso = CreateObject( "Scripting.FileSystemObject" )
        set fHWFile = fso.CreateTextFile( sCmdFileName )
        fHWFile.WriteLine "function SayHi()"
        fHWFile.WriteLine " "
        fHWFile.WriteLine vbTab & "Application.LogMessage " & Chr(34) & "Hello, World!" & Chr(34)
        fHWFile.WriteLine "end function"
        ' Add it to the command map in Softimage
        set oCmd = Application.CreateCommand( "Howdy", siNoCategory )
        oCmd.Description = "Display the traditional greeting"
        oCmd.ScriptingName = "Howdy"
        oCmd.Handler = "SayHi"
        oCmd.FileName = sCmdFileName
        oCmd.Language = "VBScript"
        Application.AddCommand oCmd 
        ' Run it just to make sure it's working
        Application.LogMessage "Logged from within makeCusCmd():"
        ' Return the name of the new command
        makeCusCmd = "Howdy"
        Application.LogMessage "========================================"
end function
function cleanUpCmd( in_sCmd2Delete )
        Application.RemoveCommand in_sCmd2Delete
        if Err.Number <> 0 then
                cleanUpCmd = false
                cleanUpCmd = true
        end if
end function
' ------------------------------------
' Output of above script:
'INFO : "Logged from within makeCusCmd():"
'INFO : "Hello, World!"
'INFO : "========================================"
'INFO : "Logged after installing from add-on:"
'INFO : "Hello, World!"

See Also