首页 > 分享 > 基础篇(基于Revit2016)

基础篇(基于Revit2016)

项目需引用两个dll,分别为RevitAPI.dll和RevitAPIUI.dll

使用RevitAPI必须继承的接口:

IExternalCommand/IExternalApplication(用于保存Revit中数据的Application和Document)

RevitAPI.dll包含访问Revit中的DB级别的Application、Document、Element以及Parameter方法,也包含了IExternalDBApplication接口和其他相关接口

RevitAPIUI.dll程序集包含了所有操作和定制RevitUI的借口,包括:

IExternalCommand相关接口;

IExternalApplication相关接口;

Selection选择;

菜单类RibbonPanel,RibbonItem以及其子类;

TaskDialogs任务对话框

Revit通过.addin文件来识别和加载外部插件

IExternalCommand是RevitAPI用户通过外部命令来扩展Revit时必须在外部命令中实现的接口。它的接口只有一个抽象函数Excute,重载这个函数来实现IExternalCommand.Excute函数将作为外部命令的主函数被调用

public Result Execute (ExternalCommandData commandData, ref string message, ElementSet elements )

        {

            return Autodesk . Revit. UI .Result . Succeeded;

        }

插件格式:

ExternalCommandData: 通过这个可以直接或间接的获取Revit的数据

message:当Excute执行失败,用来返回信息

ElementSet:元素

Result:

Autodesk.Revit.UI.Result.Succeeded

Autodesk.Revit.UI .Result.Failed

Autodesk.Revit.UI .Result.Canceled

如果返回的不是Succeeded,Revit会撤销外部所有的修改和操作

对应XML .addin

< RevitAddIns >

 < AddIn Type =" Command">

    <!-- 程序集绝对路径 -->

    < Assembly >E:VS2012DemoHelloRevitHelloRevitbinDebugHelloRevit.dll </ Assembly>

    <!-- GUID唯一值 -->

    < ClientId >7d4e1893-3a27-4df2-8075-4fa3754537aa </ ClientId>

    <!-- 插件程序集类名 -->

    < FullClassName >HelloRevit.Class1 </ FullClassName>

    < VendorId >ADSK </ VendorId>

  </ AddIn >

</RevitAddIns >

IExternalApplication接口有两个抽象函数OnStartup和OnShutdown

public interface IExternalApplication

{

     Autodesk.Revit.UI.Result OnShutDown(UIControlledApplication application);

     Autodesk.Revit.UI.Result OnStartUp(UIControlledApplication application);

}

UIControlledApplication提供访问定制UI和注册事件的方法

对应XML .addin

< RevitAddIns >

< AddIn Type =" Application">

    < Name >SampleApplication </ Name>

    <!-- 程序集绝对路径 -->

    < Assembly >E:VS2012DemoHelloRevitHelloRevitbinDebugHelloRevit.dll </ Assembly>

    <!-- GUID唯一值 -->

    < AddInId >604b1052-F742-4951-8576-C261D1993107 </ AddInId>

    <!-- 插件程序集类名 -->

    < FullClassName >HelloRevit.Class1 </ FullClassName>

    <!-- 供应商名称 -->

    < VendorId >ADSK </ VendorId>

  </ AddIn >

</RevitAddIns >

IExternalDBApplication 提供DB的基本应用

public interface IexternalDBApplication

{

     Autodesk.Revit.DB.ExternalDBApplicationResultOnShutdown(UIControlledApplication application);

     Autodesk.Revit.DB..ExternalDBApplicationResultOnStartUp(UIControlledApplication application);

}

用户可以在OnStartup方法中注册所需的DB级别的事件

Revit注册插件

1.只在当前用户可用

(win7) c:User<user>AppDataRoamingAutodeskRevitAddins2015

2.所有人可用

(win7) c:ProgramDataAutodeskRevitAddins2015

相关属性:

1.Transaction

用户必须在实现IExternalCommand 接口时指定外面命令使用的TransationMode属性(没有默认模式,需要用户指定)

例如:[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]

①TransactionMode.Automatic 将事务交给程序(Revit)控制,整体的提交或者回滚,自己可以创建SubTransactions不能再创建Transaction

②TransactionMode.Manual      自己创建事务并管理

③TransactionMode.ReadOnly   只允许读取Revit模型,在修改或创建的时候会引发Revit异常

2.Journaling(可选属性)

用于控制Revit Journal文件在执行外部命令过程中的行为

例如:[Autodesk.Revit. Attributes .Journaling(Autodesk.Revit.Attributes.JournalingMode.UsingCommandData)]

①JournalingMode.NoCommandData Revit不会将ExternalCommandData.JournalData的内容写到RevitJournal中

②JournalingMode.UsingCommandData Revit使用IDictionary<String,String>格式把ExternalCommandData.JournalData的内容写到RevitJournal中。为默认模式

相关知识

蛋糕裱花基础+花卉篇.pdf
插花花艺基础篇
植物修剪整形基础篇
花艺基础造型篇--“微景观”
花艺基础造型篇--“瀑布”造型
多肉养护基础篇:跟着学修剪花箭、枯叶,1招就能防治病虫害
零基础少儿民族民间舞蹈教学(苗苗篇)朝鲜族《漂亮的花童》
花艺基础造型篇--“扇型”
永生花DIY【基础工具篇】
植物大战僵尸花园战争 基础职业定位与技能介绍 植物篇

网址: 基础篇(基于Revit2016) https://m.huajiangbk.com/newsview665877.html

所属分类:花卉
上一篇: 鹅莓开花吗
下一篇: 花开花谢花飞花满天下联