请选择 进入手机版 | 继续访问电脑版
查看: 7551|回复: 14

Revit二次开发之注册扩展in Revit2011

    [复制链接]

发表于 2010-10-8 08:39:25 | 显示全部楼层 |阅读模式
Revit二次开发之注册扩展in Revit2011

(转自cnblogs)
Technorati Tags: revit autodesk autocad C#
Add-in Registration
External commands and external applications need to be registered in order to appear inside Revit. They can be registered in one of two ways: by adding them to the Revit.ini file or by adding them to a .addin manifest file. However, the Revit.ini method will be deprecated in a future release of Revit, making the manifest file the preferred method. For more information on registering via the Revit.ini file, see Registering Add-Ins Using Revit.ini in the appendix.
The order that external commands and applications are listed in Revit is determined by the order in which they are read in when Revit starts up. External commands and applications in the Revit.ini file are processed by Revit after commands and applications found in manifest files. The external commands and applications within the Revit.ini file are processed in the order listed in their respective sections.

注册插件
扩展命令和扩展应用需要注册才能出现在Revit中,他们可通过以下2种方式进行注册.
1就是通过revit.ini文件添加
2就是添加.addin声明文件.
由于revit.ini这种方式在以后的版本中要被取缔.所以还是建议使用声明文件的方式.关于通过revit.ini方式注册的更多的信息请阅读附录中使用revit.ini注册插件的部分.
扩展命令或者应用的顺序取决于在revit启动的时候读取他们的顺序.使用revit.ini方式的注册要在revit读取声明文件之后再读取.在revit.ini文件中排序是按照他们各自在各自的部分中的顺序来定的.
Manifest Files
Starting with Revit 2011, the Revit API offers the ability to register API applications via a .addin manifest file. Manifest files are read automatically by Revit when they are placed in one of two locations on a user's system:
In a non-user-specific location in "application data":
 For Windows XP - C:\Documents and Settings\All Users\Application Data\Autodesk\Revit\Addins\2011\
 For Vista/Windows 7 - C:\ProgramData\Autodesk\Revit\Addins\2011\
In a user-specific location in "application data":
 For Windows XP - C:\Documents and Settings\<user>\Application Data\Autodesk\Revit\Addins\2011\
 For Vista/Windows 7 - C:\Users\<user>\AppData\Roaming\Autodesk\Revit\Addins\2011\
All files named .addin in these locations will be read and processed by Revit during startup. All of the files in both the user-specific location and the all users location are considered together and loaded in alphabetical order. If an all users manifest file shares the same name with a user-specific manifest file, the all users manifest file is ignored. Within each manifest file, the external commands and external applications are loaded in the order in which they are listed.
声明文件
从revit 2011开始revit api 提供通过一个叫做.addin 的声明文件的东西来自动注册扩展.他们存在于2个地方:
1 无指定用户的地方 application data
For Windows XP - C:\Documents and Settings\All Users\Application Data\Autodesk\Revit\Addins\2011\
 For Vista/Windows 7 - C:\ProgramData\Autodesk\Revit\Addins\2011\
2 指定用户的目录
For Windows XP - C:\Documents and Settings\<user>\Application Data\Autodesk\Revit\Addins\2011\
 For Vista/Windows 7 - C:\Users\<user>\AppData\Roaming\Autodesk\Revit\Addins\2011\

所有在这些目录的.addin文件都在revit启动时被读取.这些文件将被以字母顺序放在一起.如果alluser下和用户目录下存在同名的声明文件,.alluser 的那个文件将被忽略.扩展们将被按他们在声明文件中的排列顺序排序.
这个是一般扩展目录的声明文件.
<?xml version="1.0" encoding="utf-8" standalone="no"?><RevitAddIns>Add-in IntegrationRevit 2010 API User Manual 40<AddIn Type="Command"><Assembly>c:\MyProgram\MyProgram.dll</Assembly><AddInId>76eb700a-2c85-4888-a78d-31429ecae9ed</AddInId><FullClassName>Revit.Samples.SampleCommand</FullClassName><Text>Sample command</Text><VisibilityMode>NotVisibleInFamily</VisibilityMode><VisibilityMode>NotVisibleInMEP</VisibilityMode><AvailabilityClassName>Revit.Samples.SampleAccessibilityCheck</AvailabilityClassName><LongDescription><p>This is the long description for my command.</p><p>This is another descriptive paragraph, with notes about how to use the command properly.</p></LongDescription><TooltipImage>c:\MyProgram\Autodesk.jpg</TooltipImage><LargeImage>c:\MyProgram\MyProgramIcon.png</LargeImage></AddIn></RevitAddIns>

这个是一个扩展应用的声明文件.
<?xml version="1.0" encoding="utf-8" standalone="no"?>  <RevitAddIns>  <AddIn Type="Application">  <Name>SampleApplication</Name>  <Assembly>c:\MyProgram\MyProgram.dll</Assembly>  <AddInId>604B1052-F742-4951-8576-C261D1993107</AddInId>  <FullClassName>Revit.Samples.SampleApplication</FullClassName>  </AddIn>  </RevitAddIns>        
以下是xml中一些能用的tag
assembly这个就是你指定的编译好的dll文件的完全路径
FullClassName这个是从命名空间到类名
addidguid.,一个id性质的东西
name给她起个名字
text就是在revit中显示的名字
description这个就是描述了,就是当在revit中鼠标放在addin上时显示的
VisibilityMode以下这些用的时候再查去吧
AvailabilityClassName
LargeImage
SmallImage
LongDescription
TooltipImage
LanguageType

(转自cnblogs)

评分

1

查看全部评分

回复

使用道具 举报

发表于 2010-12-16 15:16:16 | 显示全部楼层
604B1052-F742-4951-8576-C261D1993107这个是什么决定 的呢?  
回复 支持 反对

使用道具 举报

发表于 2010-12-16 15:53:00 | 显示全部楼层
AddInId怎么写呀?
回复 支持 反对

使用道具 举报

发表于 2010-12-16 19:14:54 | 显示全部楼层
楼主这不是骑着马找马吗?
回复 支持 反对

使用道具 举报

发表于 2010-12-17 09:51:50 | 显示全部楼层
回复 join09 的帖子

guid,可以通过VS的Tools->Create GUID来生成。
回复 支持 反对

使用道具 举报

发表于 2010-12-24 09:56:27 | 显示全部楼层
太复杂了,不过还是谢谢您的回复!
回复 支持 反对

使用道具 举报

发表于 2011-1-11 15:09:52 | 显示全部楼层
请问REVIT样板文件中删除哪些未使用的东西可以明显让文件容量变小?
回复 支持 反对

使用道具 举报

发表于 2011-1-22 13:50:50 | 显示全部楼层
Revit插件向导可以自动生成注册扩展:
spiderinnet.typepad.com/blog/2010/12/a-wizard-for-revit-net-addin.html
回复 支持 反对

使用道具 举报

发表于 2011-4-22 13:05:16 | 显示全部楼层
又学习了一点知识,谢谢……
回复 支持 反对

使用道具 举报

发表于 2011-7-16 20:28:09 | 显示全部楼层
有点小复杂啊!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则