Revit根据线生成墙

根据模型中模型线生成墙
在这里插入图片描述

public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            //通过commandData获取UIDocument
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            //通过uidoc获取revit当前文档
            Document doc = uidoc.Document;

            //
            ElementId leveId = new ElementId(339);
            ElementId wallTypeId = new ElementId(36772);

            
            //在revit当前文档下,进行选择元素的操作
            var reference = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);
            //获取直接选择的这个元素
            var element = doc.GetElement(reference.ElementId);
            //对所选择的元素进行类型转换(或者可以理解成指定获取元素的类别,比如:墙、楼板、屋顶等等)
            ModelLine line1 = element as ModelLine;
            Curve line = line1.GeometryCurve;

            using (Transaction transaction = new Transaction(doc))
            {
                transaction.Start("Create wall");
                Wall wall = Wall.Create(doc, line, wallTypeId, leveId, 5, 0, true, false);//.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 100, 0))
                transaction.Commit();
            }
            return Autodesk.Revit.UI.Result.Succeeded;
        }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值