Revit二次开发——场地地形

如有不明白,请qq254033230询问。

Revit的场地地形其实没有什么特别的,其实它就是一个面而已,创建这个面用下面这个方法:

Form NewFormByCap(bool isSolid, ReferenceArray profile); 

如果是做成五花肉那种的,就用另一个方法:

Form NewLoftForm(bool isSolid, ReferenceArrayArray profiles); 


首先用以下代码来创建一个地形面:

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

namespace 地形
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
    [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
    public class Class1 : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document revitDoc = commandData.Application.ActiveUIDocument.Document;  //取得文档
            Application revitApp = commandData.Application.Application;             //取得应用程序

            using (Transaction transaction = new Transaction(revitDoc))
            {
                transaction.Start("主题");
                //在下面添加主要代码内容
                //因为CurveByPoints不能是封闭曲线,所以这里建两条线
                ReferencePointArray refPointArray = new ReferencePointArray();
                ReferencePointArray refPointArray2= new ReferencePointArray();
                ReferencePoint referencePoint1 = revitDoc.FamilyCreate.NewReferencePoint(new XYZ(0,0,0));
                ReferencePoint referencePoint2 = revitDoc.FamilyCreate.NewReferencePoint(new XYZ(100, 0, 0));
                ReferencePoint referencePoint3 = revitDoc.FamilyCreate.NewReferencePoint(new XYZ(100, 100, 0));
                ReferencePoint referencePoint4 = revitDoc.FamilyCreate.NewReferencePoint(new XYZ(0, 100, 0));
                refPointArray.Append(referencePoint1);
                refPointArray.Append(referencePoint2);
                refPointArray.Append(referencePoint3);
                refPointArray.Append(referencePoint4);

                CurveByPoints curve1 = revitDoc.FamilyCreate.NewCurveByPoints(refPointArray);

                refPointArray2.Append(referencePoint1);
                refPointArray2.Append(referencePoint4);
                CurveByPoints curve2 = revitDoc.FamilyCreate.NewCurveByPoints(refPointArray2);

                ReferenceArray profile = new ReferenceArray();
                profile.Append(curve1.GeometryCurve.Reference);
                profile.Append(curve2.GeometryCurve.Reference);

                Form form = revitDoc.FamilyCreate.NewFormByCap(true, profile);



                transaction.Commit();

            }
            return Result.Succeeded;
        }
    }
}
结果如图:
创建有等高线的地形表面(核心还是用下面的这个api):

Form NewFormByCap(bool isSolid, ReferenceArray profile); 

效果如图:


如果需要变成实体则用Form NewLoftForm(bool isSolid, ReferenceArrayArray profiles); 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值