Revit二次开发示例:HelloRevit
本示例实现Revit和Revit打开的文件的相关信息。
#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;
}
}
}
Revit二次开发示例:HelloRevit的更多相关文章
- Revit二次开发示例:EventsMonitor
在该示例中,插件在Revit启动时弹出事件监控选择界面,供用户设置,也可在添加的Ribbon界面完成设置.当Revit进行相应操作时,弹出窗体会记录事件时间和名称. #region Namespace ...
- Revit二次开发示例:ErrorHandling
本示例介绍了Revit的错误处理. #region Namespaces using System; using System.Collections.Generic; using Autodes ...
- Revit二次开发示例:ChangesMonitor
在本示例中,程序监控Revit打开文件事件,并在创建的窗体中更新文件信息. #region Namespaces using System; using System.Collections.Ge ...
- Revit二次开发示例:AutoStamp
该示例中,在Revit启动时添加打印事件,在打印时向模型添加水印,打印完成后删除该水印. #region Namespaces using System; using System.Collect ...
- Revit二次开发示例:ModelessForm_ExternalEvent
使用Idling事件处理插件任务. #region Namespaces using System; using System.Collections.Generic; using Autodesk. ...
- Revit二次开发示例:Journaling
关于Revit Journal读写的例子. #region Namespaces using System; using System.Collections.Generic; using Sys ...
- Revit二次开发示例:DisableCommand
Revit API 不支持调用Revit内部命令,但可以用RevitCommandId重写它们(包含任意选项卡,菜单和右键命令).使用RevitCommandId.LookupCommandId()可 ...
- Revit二次开发示例:DesignOptions
本例只要演示Revit的类过滤器的用法,在对话框中显示DesignOption元素. #region Namespaces using System; using System.Collections ...
- Revit二次开发示例:DeleteObject
在本例中,通过命令可以删除选中的元素. 需要注意的是要在代码中加入Transaction,否则的话会出现Modifying is forbidden because the document has ...
随机推荐
- /run/systemd/private: No such file or directory
今天执行consul脚本的时候报错 /run/systemd/private: No such file or directory reboot -f 重启电脑private文件就出现了.
- JSONModel - 字符串换转实体类
JSONModel https://github.com/icanzilb/JSONModel/ 一. 获取属性的元数据 const char *attrs = property_getAttrib ...
- java对象与json对象间的相互转换
工程中所需的jar包,因为在网上不太好找,所以我将它放到我的网盘里了,如有需要随便下载. 点击下载 1.简单的解析json字符串 首先将json字符串转换为json对象,然后再解析json对象,过程如 ...
- Sublime Text 2 入门及技巧
看了 Nettuts+ 对 Sublime Text 2 的介绍, 立刻就兴奋了,诚如作者 Jeffrey Way 所说:“<永远的毁灭公爵>都发布了,TextMate 2 还没发”,你还 ...
- jQuery操作复选框的简单使用
开发中为了实现一个小功能,就是复选框的相互影响事件,如下图: 就是通过复选框设置权限,权限是分等级的,这是一个web管理系统的应用,一个管理员具有三个权限赋予,权限也是有等级的,其中删除和编辑权限相当 ...
- 3.前端笔记之JavaScript基础
作者:刘耀 部分内容参考一下链接 参考: http://www.cnblogs.com/wupeiqi/articles/5369773.html http://javascript.ruanyife ...
- Python -- BeautifulSoup的学习使用
BeautifulSoup4.3 的使用 下载和安装 # 下载 http://www.crummy.com/software/BeautifulSoup/bs4/download/ # 解压后 使用r ...
- Java程序编译和运行的过程
Java整个编译以及运行的过程相当繁琐,本文通过一个简单的程序来简单的说明整个流程. 如下图,Java程序从源文件创建到程序运行要经过两大步骤:1.源文件由编译器编译成字节码(ByteCode) 2 ...
- HDU 1521 排列组合 指数型母函数
排列组合 Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status D ...
- NEXTDAY
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "com_time ...