Revit二开之墙体创建

1.创建类库项目(自行命名)

2.添加引用信息

3.代码部分4

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CreateWallDemo
{
    [Transaction(TransactionMode.Manual)]
    public class FirstDemo_CreateWall : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            //【1】获取当前文档
            Document doc = commandData.Application.ActiveUIDocument.Document;
            //【2】获取CW 102-50-100墙的族类型
            FilteredElementCollector fel = new FilteredElementCollector(doc);
            WallType wallType = fel.OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(WallType))
                .FirstOrDefault(x => x.Name == "CW 102-50-100p") as WallType;
            //【3】获取标高
            Level level = new FilteredElementCollector(doc).OfClass(typeof(Level)).FirstOrDefault(x => x.Name == "标高 1") as Level;
            //【4】创建线
            XYZ start = new XYZ(0, 0, 0);
            XYZ end = new XYZ(10, 10, 0);
            Line line = Line.CreateBound(start, end);
            //无连接高度
            double height = 30 / 0.3048;
            double offset = 0;
            //【5】创建事务
            Transaction trans = new Transaction(doc,"创建墙");
            trans.Start();
            Wall wall = Wall.Create(doc, line, wallType.Id, level.Id, height, offset, false, false);
            trans.Commit();

            return Result.Succeeded;
        }
    }
}

4.运行代码,复制生成的dll文件路径

 

 5.在revit中加载复制的dll文件,效果如下

 

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值