本示例实现Revit和Revit打开的文件的相关信息。

  1. #region Namespaces
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using Autodesk.Revit.ApplicationServices;
  6. using Autodesk.Revit.Attributes;
  7. using Autodesk.Revit.DB;
  8. using Autodesk.Revit.UI;
  9. using Autodesk.Revit.UI.Selection;
  10. #endregion
  11.  
  12. namespace HelloRevit
  13. {
  14. [Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)]
  15. [Autodesk.Revit.Attributes.Regeneration(RegenerationOption.Manual)]
  16. [Autodesk.Revit.Attributes.Journaling(JournalingMode.NoCommandData)]
  17. public class Command : IExternalCommand
  18. {
  19. public Result Execute(
  20. ExternalCommandData commandData,
  21. ref string message,
  22. ElementSet elements)
  23. {
  24. Application app = commandData.Application.Application;
  25. Document activeDoc = commandData.Application.ActiveUIDocument.Document;
  26. TaskDialog mainDialog = new TaskDialog("Hello, Revit!");
  27. mainDialog.MainInstruction = "Hello, Revit!";
  28. mainDialog.MainContent=
  29. "This sample shows how a basic ExternalCommand can be added to the Revit user interface."
  30. + " It uses a Revit task dialog to communicate information to the interactive user.\n"
  31. + "The command links below open additional task dialogs with more information.";
  32.  
  33. mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1,
  34. "View information about the Revit installation");
  35. mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2,
  36. "View information about the active document");
  37.  
  38. mainDialog.CommonButtons = TaskDialogCommonButtons.Close;
  39. mainDialog.DefaultButton = TaskDialogResult.Close;
  40. mainDialog.FooterText=
  41. "<a href=\"http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 \">"
  42. + "Click here for the Revit API Developer Center</a>";
  43.  
  44. TaskDialogResult tResult = mainDialog.Show();
  45. if (TaskDialogResult.CommandLink1 == tResult)
  46. {
  47. TaskDialog dialog_CommandLink1 = new TaskDialog("Revit Build Informaiton");
  48. dialog_CommandLink1.MainInstruction =
  49. "Revit Version Name is: " + app.VersionName + "\n"
  50. + "Revit Version Number is: " + app.VersionNumber + "\n"
  51. + "Revit Version Build is: " + app.VersionBuild;
  52. dialog_CommandLink1.Show();
  53. }
  54. else if (TaskDialogResult.CommandLink2 == tResult)
  55. {
  56. TaskDialog.Show("Active Document Information",
  57. "Active document: " + activeDoc.Title + "\n"
  58. + "Active view name: " + activeDoc.ActiveView.Name);
  59. }
  60.  
  61. return Result.Succeeded;
  62. }
  63. }
  64. }

Revit二次开发示例:HelloRevit的更多相关文章

  1. Revit二次开发示例:EventsMonitor

    在该示例中,插件在Revit启动时弹出事件监控选择界面,供用户设置,也可在添加的Ribbon界面完成设置.当Revit进行相应操作时,弹出窗体会记录事件时间和名称. #region Namespace ...

  2. Revit二次开发示例:ErrorHandling

    本示例介绍了Revit的错误处理.   #region Namespaces using System; using System.Collections.Generic; using Autodes ...

  3. Revit二次开发示例:ChangesMonitor

    在本示例中,程序监控Revit打开文件事件,并在创建的窗体中更新文件信息.   #region Namespaces using System; using System.Collections.Ge ...

  4. Revit二次开发示例:AutoStamp

    该示例中,在Revit启动时添加打印事件,在打印时向模型添加水印,打印完成后删除该水印.   #region Namespaces using System; using System.Collect ...

  5. Revit二次开发示例:ModelessForm_ExternalEvent

    使用Idling事件处理插件任务. #region Namespaces using System; using System.Collections.Generic; using Autodesk. ...

  6. Revit二次开发示例:Journaling

    关于Revit Journal读写的例子.   #region Namespaces using System; using System.Collections.Generic; using Sys ...

  7. Revit二次开发示例:DisableCommand

    Revit API 不支持调用Revit内部命令,但可以用RevitCommandId重写它们(包含任意选项卡,菜单和右键命令).使用RevitCommandId.LookupCommandId()可 ...

  8. Revit二次开发示例:DesignOptions

    本例只要演示Revit的类过滤器的用法,在对话框中显示DesignOption元素. #region Namespaces using System; using System.Collections ...

  9. Revit二次开发示例:DeleteObject

    在本例中,通过命令可以删除选中的元素. 需要注意的是要在代码中加入Transaction,否则的话会出现Modifying  is forbidden because the document has ...

随机推荐

  1. table表头标题th浮动提示-MyTable.js

    /* $(document).ready(function () { var maxH = ($(window).height() - $("#divParent").positi ...

  2. 在Linux上使用的10种云备份方案

    导读 不久前,为用户提供一种备份远程机器上数据的简易方法还很稀奇.现在,我们已觉得这理所当然.Dropbox及其他公司简化了这项任务.苹果.谷歌和微软都提供各自的数据备份方法. 在Linux上,情况有 ...

  3. Stanford机器学习---第八讲. 支持向量机SVM

    原文: http://blog.csdn.net/abcjennifer/article/details/7849812 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回 ...

  4. opencv中,c和c++版本区别体验

    参考:http://www.cnblogs.com/tornadomeet/archive/2012/04/29/2476277.html

  5. 取出type="button" 和type="text" 里面的值显示在页面

    <script  type="text/JavaScript> function changeLink() { document.getElementById("nod ...

  6. dom 中事件

    阻止表单提交: function aa(){ return false; } function bb(event){ event.preventDefault(); } 事件不再派发: <!DO ...

  7. Android clickable 和 focusable

    setClickable(),好像是控制按钮是否可以被点击和点击之后触发监听器事件.setFocusable();控制键盘是否可以获得这个按钮的焦点.(我按实体键盘上方向键,button被选中) 今天 ...

  8. MySQL 全文搜索支持, mysql 5.6.4支持Innodb的全文检索和类memcache的nosql支持

    背景:搞个个人博客的全文搜索得用like啥的,现在mysql版本号已经大于5.6.4了也就支持了innodb的全文搜索了,刚查了下目前版本号都到MySQL Community Server 5.6.1 ...

  9. js监听密码输入框type

    1.密码输入框 <input class="oaInput oaText" type="text" placeholder="请输入用户名&qu ...

  10. 【python】异常处理

    转自:http://www.cnblogs.com/IPrograming/p/Python_error_handler.html 1. 抛出异常和自定义异常 Python用异常对象(exceptio ...