// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // // Creation Date: September 2006 // // // // // // registerPluginResource(string $pluginName, string $lookUpKey, string $defaultValue) // // // // Register a string resource for use by a plugin and assign its // default value. Once registered, the resource can be retrieved using // getPluginResource. // //

// Lookup keys must be unique. Both the plugin name and the // lookup key are used to uniquely identify the resource. // The plugin name is the same string that is passed to the // loadPlugin command. // //

// If localized resource strings are provided, they override the // intial registered value using the setPluginResource command. // Note that the resource must be registered first // before it can be overridden with other values. // //

// Plugin resources are retrieved using the getPluginResource command. // The plugin resource must be initially registered. This is done // in mel using the registerPluginResource command, or in a plugin's // code using MStringResource::registerString. After it is registered // localized values can be set onto the resource using setPluginResource. // //

// This command should be called during plugin load for each // string resource used in the plugin's script files. // Generally these calls are made in the UI string registration // procedures (see MFnPlugin::registerUIStrings). // Plugin resources used in C++ code are usually registered in the plugin // code (see MStringResource::registerString). // // // // string $pluginName Unique Plugin name (as passed to loadPlugin) // string $lookUpKey Unique key for this string resource // string $defaultValue Default string value to be associated with the resource // // // // // // Assign resource values that will be used to initialize // // menu item labels for the plugin. // // The plugin name is "myPlugin" and each resource has a unique // // key. // // The default values given for the resource will be used unless // // they are subsequently overridden using setPluginResource. // // // registerPluginResource("myPlugin", "showBBoxLabel", "Show Bounding Box"); // registerPluginResource("myPlugin", "hideBBoxLabel", "Hide Bounding Box"); // // // global proc registerPluginResource( string $pluginId, string $stringId, string $str ) { string $fullId = "p_" + $pluginId + "." + $stringId; int $exists = `displayString -exists $fullId`; if ($exists) { // Issue warning if the string is already registered $fmt = (uiRes("m_registerPluginResource.kNotRegistered")); string $msg = `format -stringArg $pluginId -stringArg $stringId $fmt`; warning $msg; // Replace the string's value displayString -replace -value $str $fullId; } else { // Set the string's default value displayString -value $str $fullId; } }