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 ...
随机推荐
- thinkphp 修改分页样式表
原网页:http://blog.csdn.net/u014175572/article/details/53116546 在这里我有先把page的设置做成了一个函数getpage, 将这个方法放到Ap ...
- 微服务深入浅出(8)-- 配置中心Spring Cloud Config
Config Server从本地读取配置文件 将所有的配置文件统一写带Config Server过程的目录下,Config Server暴露Http API接口,Config Client调用Conf ...
- Git 创建仓库【转】
转自:http://www.runoob.com/git/git-create-repository.html Git 创建仓库 本章节我们将为大家介绍如何创建一个 Git 仓库. 你可以使用一个已经 ...
- maven profile 优先级
maven profile是有优先级别 也就是说在setting.xml的profile优先级比pom中同名的profile高. 可以使用 mvn help:active-profiles 这个命令是 ...
- java使用DOM操作XML
XML DOM简介 XML DOM 是用于获取.更改.添加或删除 XML 元素的标准. XML 文档中的每个成分都是一个节点. DOM 是这样规定的: 整个文档是一个文档节点 每个 XML 标签是一个 ...
- 说一下怎么搭建外网来访问SVN服务器
一.搭建SVN服务器 1.所需软件 TortoiseSVN,下载地址http://tortoisesvn.net/downloads.html TortoiseSVN中文语言包,下载地址http:// ...
- 孤的Scrapy官文阅读进程
上月底开始学习Scrapy爬虫框架,看了一些中文文档,讲应用.讲基础的,对其有一些了解了.终于在28日打开Scrapy的官网,并制作了其文档的思维导图,进而开启了其文档的阅读之旅. 本文展示了从6月2 ...
- python面向对象(六)之元类
元类 1. 类也是对象 在大多数编程语言中,类就是一组用来描述如何生成一个对象的代码段.在Python中这一点仍然成立: In [13]: class ObjectCreator(object): . ...
- ZOJ 3469 Food Delivery(区间DP好题)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4255 题目大意:在x轴上有n个客人,每个客人每分钟增加的愤怒值不同. ...
- 20165203实验四 Andriod程序设计
20165203实验四 Andriod程序设计 实验内容 安装 Android Stuidio 学习Android Stuidio调试应用程序 实验要求 1.没有Linux基础的同学建议先学习< ...