コード例 #1
0
        /// <summary>
        /// Prompts to edit the revision and resave.
        /// </summary>
        /// <param name="application"></param>
        private void PromptToEditRevisionsAndResave(UIApplication application)
        {
            // Setup external event to be notified when activity is done
            externalEvent = ExternalEvent.Create(new PostCommandRevisionMonitorEvent(this));

            // Setup event to be notified when revisions command starts (this is a good place to raise this external event)
            RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.SheetIssuesOrRevisions);

            if (binding == null)
            {
                binding = application.CreateAddInCommandBinding(id);
            }
            binding.BeforeExecuted += ReactToRevisionsAndSchedulesCommand;

            // Post the revision editing command
            application.PostCommand(id);
        }
コード例 #2
0
        //public Guid UpdaterGuid { get; set; } = new Guid("90391154-67BB-452E-A1A7-A07A98B94F86");

        /// <summary>
        /// Creates an idling task that will bind our own Reload Latest command to existing one.
        /// </summary>
        public static void CreateLinkUnloadOverride(UIApplication app)
        {
            try
            {
                var commandId = RevitCommandId.LookupCommandId("ID_UNLOAD_FOR_ALL_USERS");
                if (commandId == null || !commandId.CanHaveBinding)
                {
                    return;
                }

                var binding = app.CreateAddInCommandBinding(commandId);
                binding.Executed += OnUnloadForAllUsers;
            }
            catch (Exception e)
            {
                Log.AppendLog(LogMessageType.EXCEPTION, e.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// 提示编辑修订版本号,并重新保存
        /// </summary>
        /// <param name="application"></param>
        private void PromptToEditRevisionsAndResave(UIApplication application)
        {
            // Setup external event to be notified when activity is done
            externalEvent = ExternalEvent.Create(new PostCommandRevisionMonitorEventHandler(this));

            // Setup event to be notified when revisions command starts (this is a good place to raise this external event)
            RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.SheetIssuesOrRevisions);

            if (binding == null)
            {
                binding = application.CreateAddInCommandBinding(id);
            }

            binding.BeforeExecuted += ReactToRevisionsAndSchedulesCommand;
            //在执行RevitCommandId之前,执行externalEvent,也就是 CleanupAfterRevisionEdit 方法,这个方法注销了注册的事件,并 repost了 Save 命令
            //这里为什么要使用外部事件?先执行屏蔽“未保存文件”对话框,然后外部事件排队,执行修订命令的对话框,执行结束后revit空闲,这里才执行 CleanupAfterRevisionEdit 方法,注销事件(以防止影响到其他命令),在调用保存方法。

            // Post the revision editing command
            application.PostCommand(id);
        }