Cleanup you menus

Publié le par Mr_Cappuccino

With the new softimage 2011.5 version, the ICE section that was in the simulate panel was replaced by the new ICE Panel.

this is great, but what if had some script commands in there and your studio still have prior Softimage versions?

 

Here is a script snipet that will check for the version and put the command in the good menu, just put it in the XSILoadPlugin function like this:

 

 

function XSILoadPlugin( in_reg )
{
    in_reg.Author = "Ahmidou lyazidi";
    in_reg.Name = "MyCommand";
    in_reg.Major = 1;
    in_reg.Minor = 0;

    in_reg.RegisterCommand("MyCommand","MyCommand");
    
    //Check for softimage version to feed the menu ( New ICE menu if >= 9.5, else, old simulate)
    var s = Application.Version().split(".")
    if (parseFloat(s[0]+"."+s[1])>= 9.5)
    {
        in_reg.RegisterMenu (siMenuTbICEParticlesCreateID,"My_Menu", false, true)    
    }
    else
    {
        in_reg.RegisterMenu(siMenuTbICECreateID,"My_Menu",false,false);
    }

    return true;
}

 

and if you want to use the new named subsection in that menu:

 

function My_Menu_Init( in_ctxt )
{
    var oMenu;
    oMenu = in_ctxt.Source;
    try
    {
        var oItem = oMenu.AddItem( "Fur", siMenuItemSection)
        oItem.SetBackgroundColor (178, 191, 194    )
    }
    catch(e)
    {
        //do nothing
    }
    oMenu.AddCallbackItem("MyCommand","MyCommand");
    return true;
}

Commenter cet article