Revit二次开发示例:HelloRevit
2014-03-19 17:17
477 查看
本示例实现Revit和Revit打开的文件的相关信息。
View Code
#region Namespaces using System; using System.Collections.Generic; using System.Diagnostics; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; #endregion namespace HelloRevit { [Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)] [Autodesk.Revit.Attributes.Regeneration(RegenerationOption.Manual)] [Autodesk.Revit.Attributes.Journaling(JournalingMode.NoCommandData)] public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { Application app = commandData.Application.Application; Document activeDoc = commandData.Application.ActiveUIDocument.Document; TaskDialog mainDialog = new TaskDialog("Hello, Revit!"); mainDialog.MainInstruction = "Hello, Revit!"; mainDialog.MainContent= "This sample shows how a basic ExternalCommand can be added to the Revit user interface." + " It uses a Revit task dialog to communicate information to the interactive user.\n" + "The command links below open additional task dialogs with more information."; mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "View information about the Revit installation"); mainDialog.AddCommandLink(TaskDialogCommandLinkId.CommandLink2, "View information about the active document"); mainDialog.CommonButtons = TaskDialogCommonButtons.Close; mainDialog.DefaultButton = TaskDialogResult.Close; mainDialog.FooterText= "<a href=\"http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=2484975 \">" + "Click here for the Revit API Developer Center</a>"; TaskDialogResult tResult = mainDialog.Show(); if (TaskDialogResult.CommandLink1 == tResult) { TaskDialog dialog_CommandLink1 = new TaskDialog("Revit Build Informaiton"); dialog_CommandLink1.MainInstruction = "Revit Version Name is: " + app.VersionName + "\n" + "Revit Version Number is: " + app.VersionNumber + "\n" + "Revit Version Build is: " + app.VersionBuild; dialog_CommandLink1.Show(); } else if (TaskDialogResult.CommandLink2 == tResult) { TaskDialog.Show("Active Document Information", "Active document: " + activeDoc.Title + "\n" + "Active view name: " + activeDoc.ActiveView.Name); } return Result.Succeeded; } } }
View Code
相关文章推荐
- Revit二次开发示例:ErrorHandling
- 配送短信猫二次开发接口软件,提供多种开发语言示例
- Revit 二次开发 - 多文档处理
- Revit 二次开发现状(2009)
- Building Coder(Revit 二次开发) - 分解DWG文件
- 可以用C++来二次开发Revit吗?
- Revit 二次开发之多线程
- Building Coder(Revit 二次开发) - 创建与墙体平行的剖视图
- <Revit二次开发> Create Doors in Wall
- Building Coder(Revit 二次开发) - 失败处理API(下)
- C# revit 二次开发 创建线样式LineStyle
- Building Coder(Revit 二次开发) - 参数访问和计划信息
- Building Coder(Revit 二次开发) - 使用 FindReferencesByDirection 创建墙体之间的尺寸标注
- Building Coder(Revit 二次开发) - 族元素可见性
- Revit 二次开发 修改对象的颜色
- Revit 2011 二次开发入门
- Revit二次开发,VS中配置
- Revit 2012 二次开发最新API网络课程录像下载
- Building Coder(Revit 二次开发) - 元素层级事件(上)
- Revit 二次开发之IFailuresProcessor