Hi @lwlXUTTT ,
Please add the RevitAPIMacros.dll
and RevitAPIUIMacros.dll
to your project.
Use the following code to configure the application and document macro security settings.
Document doc = commandData.Application.ActiveUIDocument.Document;
//Set application macro security settings
Application app = doc.Application;
MacroManager.SetApplicationMacroSecurityOptions(app,ApplicationMacroOptions.DisableMacros);
//Set document macro security settings
UIMacroManager.SetUIDocumentMacroSecurityOptions(commandData.Application, UIDocumentMacroOptions.DisableMacros);