Revit二次开发创建墙体

一、了解墙体创建基础条件

该墙体创建采用以下方法实现创建 :

  Wall.Creat(Document document,Curve curve,ElementId wallTypeId,ElementId levelId,
  double height,double offSet,bool fip,bool structural);

在这里插入图片描述

二、创建代码

    [Transaction(TransactionMode.Manual)]
    public class CreatWall : IExternalCommand
    {

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            //获得文档中墙体类型
            ElementId wallTyId = doc.GetDefaultElementTypeId(ElementTypeGroup.WallType);
            //参加墙体线
            Line wCenterLine = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(1500 / 304.8, 0, 0));
            //获取墙体所在的楼层
            ElementId levellId = doc.ActiveView.GenLevel.Id;
            //定义墙体的高度
            double hight = 3000 / 304.8;
            //墙体底部偏移
            double botOffSet = 100 / 304.8;
            //内外侧
            bool fip = false;
            //定义是否为结构墙体
            bool IsStruc= false;
            //新建并启动事务
            Transaction trans = new Transaction(doc, "创建墙体");
            trans.Start();
            Wall wall = Wall.Create(doc, wCenterLine,wallTyId, levellId, hight, botOffSet, fip, IsStruc);
            trans.Commit();![请添加图片描述](https://img-blog.csdnimg.cn/direct/565f3b5b6872441fabaf9c3f1b076944.gif)

            return Result.Succeeded;
        }
    }

三 、演示效果

在这里插入图片描述

四、注意事项

该程序运行,只能在平面中创建,因为levellId是通过当前视图获取的,三维视图无法获取到所需的构件楼层标高,用户为了程序不报错,可以将创建部分通过 try{}catch{}处理,当用户在三维视图中进行操作时候,进行提示,让其切换到平面视图中创建。

  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值