public Result OnStartup(UIControlledApplication application) { try { myCommand = new NeSync(); //构建外部事件任务 hander = ExternalEvent.Create(myCommand); //构建外部事件启动器 //注册DocumentChanged事件 application.ControlledApplication.DocumentChanged += new EventHandler <DocumentChangedEventArgs>(DocumentChangedForSomething); } catch (Exception) { return(Result.Failed); } return(Result.Succeeded); }
public ExternalEvent hander = null; //声明Reivt外部事件 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiApp = commandData.Application; Autodesk.Revit.ApplicationServices.Application app = uiApp.Application; try { myCommand = new NeSync(); //构建外部事件任务 hander = ExternalEvent.Create(myCommand); //构建外部事件启动器 //注册DocumentChanged事件 app.DocumentChanged += new EventHandler <DocumentChangedEventArgs>(DocumentChangedForSomething); } catch (Exception) { return(Result.Failed); } return(Result.Succeeded); }