简体   繁体   English

如何从Revit API调用Revit清除按钮

[英]How to Call Revit Purge Button from the Revit API

I'm developing a plugin to detached a document from central and when its done it will be purged as well. 我正在开发一个插件,用于从中央分离文档,完成后也会清除它。 I'm struggling writing the code for purge, I'm thinking to call the Revit Purge button from the code . 我正在努力编写清除代码,正在考虑从代码中调用Revit清除按钮 If it is possible, would appreciate the support or maybe share the code for writing the purge command in the API. 如果可能,请提供支持,或者共享用于在API中编写清除命令的代码。

Thank you 谢谢

With some research I have come up with the solution but it comes with few limitations too. 通过一些研究,我想出了解决方案,但是它也没有什么限制。 We can call the Revit buttons from the API, including Purge. 我们可以从API调用Revit按钮,包括Purge。

Limitations: 局限性:

  • You can't call a button from half way through your plugin. 您无法从插件的中途调用按钮。
    • You have to set it up to run after your plugin is done. 您必须将其设置为在插件完成后才能运行。
    • You might be able to get around this with subscribing to the Executed event but I'll need to experiment with that. 您可以通过订阅Executed事件来解决此问题,但我需要对此进行试验。
  • You don't know whether the command will run successfully. 您不知道该命令是否将成功运行。
    • Also, as you can't run it half way through your program, you have no way of checking whether it's succeeded within code. 另外,由于无法在程序中途运行它,因此无法检查代码中是否成功。
    • You can check the journal logs and parse the result of the latest command but that's a very hack-y feeling solution. 您可以检查日志日志并解析最新命令的结果,但这是一个非常骇人听闻的解决方案。
  • You don't know ahead of time whether someone else has overridden the button to do something else. 您无法提前知道其他人是否已重写按钮来执行其他操作。
    • The call is to just press the button. 呼叫只是按一下按钮。 The article above focuses on overriding buttons. 上面的文章重点介绍了覆盖按钮。 You can't guarantee that the button still does what you're expecting it to. 您不能保证该按钮仍然可以实现您期望的功能。
  • The process you trigger by pressing the button cannot be automated. 按下按钮触发的过程无法自动执行。
    • Your script has to finish before the button is pressed so you can't take control of the resulting dialogs. 您的脚本必须在按下按钮之前完成,这样您才能控制生成的对话框。
    • You may be able to subscribe to the button events and fiddle something that way. 您也许可以订阅按钮事件并以这种方式摆弄一些东西。 Again, experimentation needed. 同样,需要进行实验。

Following is the sample code to achieve this: 以下是实现此目的的示例代码:

        UIApplication uiapp = commandData.Application;

        //Store the ID of desired plugin button, in this case its 'purge unused'
        String s_commandToDisable = "ID_PURGE_UNUSED";
        RevitCommandId s_commandId = RevitCommandId.LookupCommandId(s_commandToDisable);

        //This revit button will run at the end of your application. 
        uiapp.PostCommand(s_commandId);

To find list of default revit command id, click here 要查找默认的revit命令ID列表,请单击此处

建筑编码器提供了有关清除和检测空视图的讨论中一些清除示例的摘要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM