PDA

View Full Version : Create Shelf buttons dynamically


anandvtra
05-24-2011, 06:01 AM
I have wrote a custom move manipulator plugin. I want load the manipulator icon on to the shelf when loading my plugin. How can I do this? Please help...


regards,
anand

reepete
05-25-2011, 01:39 PM
I have wrote a custom move manipulator plugin. I want load the manipulator icon on to the shelf when loading my plugin. How can I do this? Please help...


regards,
anand
There is a "registerUI" callback available in the load plugin method. You can call a mel script to do whatever you want on plugin load (including adding a shelf button). In this case the global procedure "lassoToolCreateUI" is called when this plugin is loaded.

HTH

Example from maya api help docs -- look under MFnPlugin

MStatus initializePlugin( MObject obj )
{
MStatus status;

MFnPlugin plugin( obj, "Autodesk - Example", "1.0", "Any");
status = plugin.registerContextCommand( "lassoToolContext",
lassoContextCmd::creator );

if (!status) {
status.perror("registerContextCommand");
return status;
}

// set the mel procs to be run when the plugin is loaded / unloaded
status = plugin.registerUI("lassoToolCreateUI", "lassoToolDeleteUI");
if (!status) {
status.perror("registerUIScripts");
return status;
}

return status;
}

anandvtra
05-26-2011, 04:15 AM
There is a "registerUI" callback available in the load plugin method. You can call a mel script to do whatever you want on plugin load (including adding a shelf button). In this case the global procedure "lassoToolCreateUI" is called when this plugin is loaded.

HTH

Example from maya api help docs -- look under MFnPlugin

MStatus initializePlugin( MObject obj )
{
MStatus status;

MFnPlugin plugin( obj, "Autodesk - Example", "1.0", "Any");
status = plugin.registerContextCommand( "lassoToolContext",
lassoContextCmd::creator );

if (!status) {
status.perror("registerContextCommand");
return status;
}

// set the mel procs to be run when the plugin is loaded / unloaded
status = plugin.registerUI("lassoToolCreateUI", "lassoToolDeleteUI");
if (!status) {
status.perror("registerUIScripts");
return status;
}

return status;
}

Maya crashes on loading the plugin...

The code I used as follows...

MStatus initializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj, PLUGIN_COMPANY, "3.0", "Any");




status = plugin.registerContextCommand("moveManipContext",
&moveManipContext::creator);
if (!status) {
MGlobal::displayError("Error registering moveManipContext command");
return status;
}
status = plugin.registerNode("moveManip", moveManip::id,
&moveManip::creator, &moveManip::initialize,
MPxNode::kManipContainer);
if (!status) {
MGlobal::displayError("Error registering moveManip node");
return status;
}
status = plugin.registerUI("CreateMoveToolUI","DeleteMoveToolUI");//Portion I added now
if(!status)
{
MGlobal::displayError("Error registering moveManip UI");
}
return status;
}




MStatus uninitializePlugin(MObject obj)
{
MStatus status;
MFnPlugin plugin(obj);
status = plugin.deregisterContextCommand("moveManipContext");
if (!status) {
MGlobal::displayError("Error deregistering moveManipContext command");
return status;
}
status = plugin.deregisterNode(moveManip::id);
if (!status) {
MGlobal::displayError("Error deregistering moveManip node");
return status;
}
return status;
}

reepete
05-26-2011, 01:37 PM
Does it crash without the part you added?

dbsmith
05-26-2011, 09:36 PM
Have you defined these as MEL global methods anywhere?:
CreateMoveToolUI
DeleteMoveToolUI

anandvtra
05-30-2011, 04:17 AM
Does it crash without the part you added?

no it works well without that part....

anandvtra
05-30-2011, 04:18 AM
Have you defined these as MEL global methods anywhere?:
CreateMoveToolUI
DeleteMoveToolUI

I defined it in the mel script editor

CGTalk Moderation
05-30-2011, 04:18 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.