@Anonymous
In this case you have not define command with CommandMethod attribute, but define with help of Autodesk.AutoCAD.Internal.Utils.AddCommand(string cmdGroupName, string cmdGlobalName, string cmdLocalName, CommandFlags cmdFlags, CommandCallback func) method in your IExtensionApplication.Initialize method only if you condition allowed it.
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Internal;
// This line is not mandatory, but improves loading performances
[assembly: ExtensionApplication(typeof(CommandUtils.MyPlugin))]
namespace CommandUtils
{
public class MyPlugin : IExtensionApplication
{
static bool condition = false;
void IExtensionApplication.Initialize()
{
if (condition)
{
Utils.AddCommand("RIVILIS", "TEST1", "ТЕСТ1", CommandFlags.Modal, CommandHandler1);
Utils.AddCommand("RIVILIS", "TEST2", "ТЕСТ2", CommandFlags.Modal, CommandHandler2);
}
}
void IExtensionApplication.Terminate()
{
if (condition)
{
Utils.RemoveCommand("RIVILIS", "TEST1");
Utils.RemoveCommand("RIVILIS", "TEST2");
}
}
public void CommandHandler1()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("\nCommand Test1");
}
public void CommandHandler2()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("\nCommand Test2");
}
}
}
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
