Message 1 of 20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an External Application that subscribes to the DocumentCreated event in order to execute a command I created for every new document. But, for whatever reason, the event handler (ExecuteCommands) is never triggered. I have a similar setup for a different Application that works just fine so I don't understand what I could be missing.
Any ideas? The code for the application is pretty short so I added it below for reference:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI;
namespace NewDocApplication
{
public class NewDoc : IExternalApplication
{
public Result OnStartup(UIControlledApplication uiConApp)
{
uiConApp.ControlledApplication.DocumentCreated += ExecuteCommands;
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication uiConApp)
{
uiConApp.ControlledApplication.DocumentCreated -= ExecuteCommands;
return Result.Succeeded;
}
public void ExecuteCommands(object sender, DocumentCreatedEventArgs args)
{
UIApplication uiapp = (UIApplication)sender;
var command = new PracticeMenu.Main();
command.Execute(uiapp);
}
}
}
Solved! Go to Solution.