zoukankan      html  css  js  c++  java
  • vs2019 对Revit的二次开发Hello World

    新建

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

    添加引用

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

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

    设置

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

    (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;
            }
        }
    }

    生成

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

    (2)生成

      Debug目录下会生成HelloWorld.dll 

    部署

    在C:UsersAdministratorAppDataRoamingAutodeskRevitAddins2018添加

    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】,选择注册表格式,复制,去掉括号

    载入

     就可以看到插件了

    点击

  • 相关阅读:
    域用户组策略禁用QQ等软件
    关于使用IDE制作样式表后不能正常显示的问题
    asp.net中使用ckfinder2选择图片并返回图片文件的路径的代码
    按规定长度显示指定绑定字段的内容
    ckeeditor和ckfinder在asp.net中的使用
    开发播放器中所学/用到的知识
    用户体验的网站首页设计的准则
    0410_gdgrid_checkbox_自己强加的多选,选中,批量删除
    0405_hxtx_主题游常用联系人功能代码实现
    0401flag
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/13291563.html
Copyright © 2011-2022 走看看