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

    载入

     就可以看到插件了

    点击

  • 相关阅读:
    19.2.15 [LeetCode 80] Remove Duplicates from Sorted Array II
    19.2.15 [LeetCode 79] Word Search
    19.2.15 [LeetCode 78] Subsets
    19.2.15 [LeetCode 77] Combinations
    19.2.15 [LeetCode 76] Minimum Window Substring
    19.2.13 [LeetCode 75] Sort Colors
    19.2.13 [LeetCode 74] Search a 2D Matrix
    19.2.13 [LeetCode 73] Set Matrix Zeroes
    19.2.13 [LeetCode 72] Edit Distance
    19.2.13 [LeetCode 71] Simplify Path
  • 原文地址:https://www.cnblogs.com/chenyanbin/p/13291563.html
Copyright © 2011-2022 走看看