Revit二次开发示例:APIAppStartup
下面介绍一个在Revit启动和关闭时调用外部程序的例子。
Revit调用的dll主程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using Autodesk;
using Autodesk.Revit;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices; namespace APIAppStartup
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class AppSample:IExternalApplication
{
#region IExternalApplication Members public Result OnShutdown(UIControlledApplication application)
{
TaskDialog.Show("Revit", "Quit External Application!");
return Result.Succeeded;
} public Result OnStartup(UIControlledApplication application)
{
string version = application.ControlledApplication.VersionName; //display splash window for 10 seconds
SplashWindow.StartSplash();
SplashWindow.ShowVersion(version);
System.Threading.Thread.Sleep(10000);
SplashWindow.StopSplash(); return Result.Succeeded;
} #endregion
}
}
在Revit启动时调用的启动画面程序:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms; namespace APIAppStartup
{ public delegate void DelegateCloseSplash(); public partial class SplashWindow : Form
{
public SplashWindow()
{
InitializeComponent();
m_delegateClose = new DelegateCloseSplash(InternalCloseSplash);
} private DelegateCloseSplash m_delegateClose;
private static SplashWindow m_instance;
private static Thread InstanceCaller; //start a new thread to display splash window
public static void StartSplash()
{
m_instance = new SplashWindow();
m_instance.TopMost = true;
InstanceCaller = new Thread(new ThreadStart(MySplashThreadFunc));
InstanceCaller.Start();
} //kill the thread
public static void StopSplash()
{
if (m_instance != null)
{
m_instance.Invoke(m_instance.m_delegateClose);
}
} //show Revit version info
public static void ShowVersion(string version)
{
m_instance.Version.Text = version;
} void InternalCloseSplash()
{
this.Close();
this.Dispose();
} //this is called by the new thread to show the splash screen
private static void MySplashThreadFunc()
{
if (m_instance != null)
{
m_instance.TopMost = true;
m_instance.ShowDialog();
}
}
}
}
Addin文件:
<?xml version="1.0" encoding="utf-8"?>
<RevitAddIns>
<AddIn Type="Application">
<Name>APIAppStartup</Name>
<Assembly>
C:\Users\Administrator\documents\visual studio 2012\Projects\APIAppStartup\APIAppStartup\bin\Release\APIAppStartup.dll
</Assembly>
<AddInId>502fe383-2648-4e98-adf8-5e6047f9dc34</AddInId>
<FullClassName>APIAppStartup.AppSample</FullClassName>
<VendorId>ADSK</VendorId>
<VendorDescription>http://xpvincent.cnblogs.com</VendorDescription>
</AddIn>
</RevitAddIns>
Revit二次开发示例:APIAppStartup的更多相关文章
- Revit二次开发示例:HelloRevit
本示例实现Revit和Revit打开的文件的相关信息. #region Namespaces using System; using System.Collections.Generic; using ...
- 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 ...
随机推荐
- java反射三种获得类类型的方法
public class Test { public static void main(String[] args) { Test t=new Test();//所有的类都是Class类的实例(类类型 ...
- C++利用cin输入时检测回车的方法
今天做TJU的OJ ,其中一道题是先读入一个字符串,再读入一个整数,循环往复,直到字符串是空,也就是说回车键结束循环. 但是cin对空格和回车都不敏感,都不影响继续读入数据,所以需要一种新的方式检测回 ...
- python类和对象-扩展
1.为类或对象动态创建属性或方法 2.__slots__ = ('name','age'),[实例]只能创建指定的属性属性或方法 ---新式类 3.执行父类的构造函数的不同Father.__init_ ...
- 查看Linux系统版本的几种方法
第一种: cat /etc/os-release # 或者 cat /etc/redhat-release 结果如下: NAME="Ubuntu" VERSION="16 ...
- Hibernate5笔记1--Hibernate简介和第一个程序
Hibernate简介: Hibernate是一个开放源代码的ORM(对象关系映射)框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库. Hib ...
- device tree --- #address-cells and #size-cells property【转】
转自:http://www.cnblogs.com/youchihwang/p/7050846.html device tree source Example1 / { #address-cells ...
- Linux Kernel sys_call_table、Kernel Symbols Export Table Generation Principle、Difference Between System Calls Entrance In 32bit、64bit Linux【转】
转自:http://www.cnblogs.com/LittleHann/p/4127096.html 目录 1. sys_call_table:系统调用表 2. 内核符号导出表:Kernel-Sym ...
- rsync本地及远程复制备份【原创】
1.安装rsyncyum instsall rsync 2.本地复制 rsync -auq --progress --delete /tongbu1/ /tongbu2/ rsync -auq --p ...
- qt使用动态库(DLL)
本文主要讲解在QT开发环境中如何使用VC生成的DLL及QT自身生成的DLL.至于其它情况本文不作讨论. 连接库分为2种 (1)动态连接库,通常有.h .lib .dll三个文件,功能实现在dll中 ( ...
- 170406回顾-SQL Server的smalldatetime类型比较
在比较SQL Server的类型为smalldatetime字段时出现下面的错误:将 expression 转换为数据类型 smalldatetime 时出现算术溢出错误 正确的比较方法如下:将lon ...