zl程序教程

您现在的位置是:首页 >  其他

当前栏目

vs2015对revit2018二次开发之helloworld详解编程语言

编程语言 详解 二次开发 HelloWorld VS2015 revit2018
2023-06-13 09:11:53 时间

【新建项目】→【Visual C#】→【类库】

vs2015对revit2018二次开发之helloworld详解编程语言

 2.添加引用

【项目】→【添加引用】→【浏览】

vs2015对revit2018二次开发之helloworld详解编程语言

 在Revit安装目录下找到【RevitAPI.dll】和【RevitAPIUI.dll】并添加

vs2015对revit2018二次开发之helloworld详解编程语言

 3.设置

(1)右键【RevitAPI】和【RevitAPIUI】,点击【属性】,将属性【复制本地】改False

vs2015对revit2018二次开发之helloworld详解编程语言

 vs2015对revit2018二次开发之helloworld详解编程语言

 (2)修改类名

Class1改为Test

using System; 

using System.Collections.Generic; 

using System.Linq; 

using System.Text; 

using System.Threading.Tasks; 

using Autodesk.Revit.DB; 

using Autodesk.Revit.UI; 

using Autodesk.Revit.Attributes; 

namespace HelloWorld 

 [Transaction(TransactionMode.Manual)] 

 public class Test:IExternalCommand 

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

 try 

 TaskDialog.Show("Hello", "First Revit Program."); 

 catch (Exception e) 

 message = e.Message; 

 return Result.Failed; 

 return Result.Succeeded; 

}

4.生成

(1)【项目】→【属性】→【调试】→【启动外部程序】,找到Revit安装目录,选择Revit.exe

(2)生成

Debug目录下会生成HelloWorld.dll 

5.部署

在C:/Users/Administrator/AppData/Roaming/Autodesk/Revit/Addins/2018添加

HelloWorld.addin

内容为

 ?xml version="1.0" encoding="utf-8"? 

 RevitAddIns 

 AddIn Type="Command" 

 VendorId abc /VendorId 

 Text Hello Workd /Text 

 Description This is Hello World for revit. /Description 

 FullClassName HelloWorld.Test /FullClassName 

 Assembly E:/C/revit/HelloWorld/HelloWorld/bin/Debug/helloworld.dll /Assembly 

 AddInId 6869D1FB-8A0D-4738-958D-1596E99A8244 /AddInId 

 /AddIn 

 /RevitAddIns 

说明:

VendorId:开发商Id
Text:插件的名称
Description:插件的描述信息 
FullClassName:命名空间.类名
Assembly:刚刚生成的dll路径
AddIn:在VS的【工具】→【创建GUID】,选择注册表格式,复制,去掉括号

vs2015对revit2018二次开发之helloworld详解编程语言

载入

vs2015对revit2018二次开发之helloworld详解编程语言

 就可以看到插件了

 vs2015对revit2018二次开发之helloworld详解编程语言

 点击

vs2015对revit2018二次开发之helloworld详解编程语言

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/20332.html

cjavaxml