Revit SDK 介绍:NewForm 新建体量

前言

这个例子介绍如何新建体量。

内容

图形生成效果。
Revit SDK 介绍:NewForm 新建体量_第1张图片

用 Extrusion 创建体量

// 创建一个轮廓
ReferenceArray ref_ar = new ReferenceArray();
// 创建三条直线,并放入轮廓
Autodesk.Revit.DB.XYZ ptA = new Autodesk.Revit.DB.XYZ(10, 10, 0);
Autodesk.Revit.DB.XYZ ptB = new Autodesk.Revit.DB.XYZ(90, 10, 0);
ModelCurve modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(90, 10, 0);
ptB = new Autodesk.Revit.DB.XYZ(10, 90, 0);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(10, 90, 0);
ptB = new Autodesk.Revit.DB.XYZ(10, 10, 0);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
// 拉伸的方向
Autodesk.Revit.DB.XYZ direction = new Autodesk.Revit.DB.XYZ(0, 0, 50);
// 创建拉伸体
Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewExtrusionForm(true, ref_ar, direction);

创建 Cap 体量

// 创建一个轮廓
ReferenceArray ref_ar = new ReferenceArray();
Autodesk.Revit.DB.XYZ ptA = new Autodesk.Revit.DB.XYZ(10, 10, 0);
Autodesk.Revit.DB.XYZ ptB = new Autodesk.Revit.DB.XYZ(100, 10, 0);
Line line = Line.CreateBound(ptA, ptB);
ModelCurve modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(100, 10, 0);
ptB = new Autodesk.Revit.DB.XYZ(50, 50, 0);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(50, 50, 0);
ptB = new Autodesk.Revit.DB.XYZ(10, 10, 0);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
// 创建一个封闭面Cap体量
Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewFormByCap(true, ref_ar);

创建旋转体体量

// 创建一个轮廓
ReferenceArray ref_ar = new ReferenceArray();
Autodesk.Revit.DB.XYZ norm = Autodesk.Revit.DB.XYZ.BasisZ;
Autodesk.Revit.DB.XYZ ptA = new Autodesk.Revit.DB.XYZ(0, 0, 10);
Autodesk.Revit.DB.XYZ ptB = new Autodesk.Revit.DB.XYZ(100, 0, 10);
ModelCurve modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB, norm);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(100, 0, 10);
ptB = new Autodesk.Revit.DB.XYZ(100, 100, 10);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB, norm);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
ptA = new Autodesk.Revit.DB.XYZ(100, 100, 10);
ptB = new Autodesk.Revit.DB.XYZ(0, 0, 10);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB, norm);
ref_ar.Append(modelcurve.GeometryCurve.Reference);
// 创建旋转轴
ptA = new Autodesk.Revit.DB.XYZ(-5, 0, 10);
ptB = new Autodesk.Revit.DB.XYZ(-5, 10, 10);
ModelCurve axis = FormUtils.MakeLine(commandData.Application, ptA, ptB, norm);
axis.ChangeToReferenceLine();
// 创建旋转体体量
Autodesk.Revit.DB.FormArray form = doc.FamilyCreate.NewRevolveForms(true, ref_ar, axis.GeometryCurve.Reference, 0, Math.PI / 4);

创建放样体量

// 创建4个轮廓(内容省略)
ReferenceArrayArray ref_ar_ar = new ReferenceArrayArray();
ReferenceArray ref_ar = new ReferenceArray();
ref_ar_ar.Append(ref_ar);
ref_ar = new ReferenceArray();
ref_ar_ar.Append(ref_ar);
ref_ar = new ReferenceArray();
ref_ar_ar.Append(ref_ar);
ref_ar = new ReferenceArray();
ref_ar_ar.Append(ref_ar);
// 创建扫掠体体量
Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewLoftForm(true, ref_ar_ar);

创建扫掠放样体量

// 创建两个轮廓(内容省略)
ReferenceArray ref_ar = new ReferenceArray();
ReferenceArray ref_ar2 = new ReferenceArray();
ReferenceArrayArray profiles = new ReferenceArrayArray();
profiles.Append(ref_ar);
profiles.Append(ref_ar2);
// 创建用于扫掠的路径
ReferenceArray path = new ReferenceArray();
ptA = new Autodesk.Revit.DB.XYZ(10, 10, 0);
ptB = new Autodesk.Revit.DB.XYZ(10, 10, 90);
modelcurve = FormUtils.MakeLine(commandData.Application, ptA, ptB);
path.Append(modelcurve.GeometryCurve.Reference);
// 创建扫掠放样体量
Autodesk.Revit.DB.Form form = doc.FamilyCreate.NewSweptBlendForm(true, path, profiles);

注意

NewLoftForm 这个例子有bug,多加了一个空的 Profile。

你可能感兴趣的:(Revit,SDK,介绍,C#)