创建异形墙

这篇博客详细介绍了如何利用Autodesk Revit API在Revit中创建一个手动交易模式的异形墙。首先,定义了XYZ坐标点,然后创建边界曲线,接着获取默认的墙类型ID和当前视图的水平面ID,最后通过指定的曲线、墙类型和水平面创建异形墙。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

namespace WallCreat
{
    [Transaction(TransactionMode.Manual)]
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document doc = uidoc.Document;
            IList<Curve> curves = new List<Curve>();
            XYZ p1 = new XYZ(0, 0, 0);
            XYZ p2 = new XYZ(3, 0, 5);
            XYZ p3 = new XYZ(0, 0, 10);
            Curve line1 = Line.CreateBound(p1,p2);
            Curve line2 = Line.CreateBound(p2,p3);
            Curve line3 = Line.CreateBound(p3, p1);
            curves.Add(line1);
            curves.Add(line2);
            curves.Add(line3);
            ElementId wallTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.WallType);
            ElementId levelId = doc.ActiveView.GenLevel.Id;
            Plane wallPlane = Plane.CreateByThreePoints(p1, p2, p3);
            XYZ normal = wallPlane.Normal;
            Transaction transaction = new Transaction(doc, "创建异形墙");
            transaction.Start();
            Wall wall = Wall.Create(doc, curves, wallTypeId, levelId, true, normal);
            transaction.Commit();
            return Result.Succeeded;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值