700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 【Revit二次开发】楼板 天花板 屋顶和洞口

【Revit二次开发】楼板 天花板 屋顶和洞口

时间:2021-02-07 16:00:53

相关推荐

【Revit二次开发】楼板 天花板 屋顶和洞口

介绍代码

介绍

Creates a slab within the project with the given horizontal profile using the default floor style.

public Floor NewSlab(CurveArray profile,Level level,Line slopedArrow,double slope,bool isStructural)

在Revit二次开发中,楼板、天花板、屋顶和洞口都是Revit中的构件类型,可以使用Revit API来创建、修改和删除这些构件。

楼板(Floor):在Revit中,楼板是由一个或多个边界定义的平面构件。可以使用Floor类来创建、修改和删除楼板。下面是一个创建楼板的示例:

// 创建一个新的楼板Floor floor = doc.Create.NewFloor(profile, floorType, level, false);

其中,profile是一个CurveArray对象,表示楼板的边界,floorType是楼板类型,level是楼板所在的标高。

天花板(Ceiling):在Revit中,天花板是一个平面构件,它被放置在房间上方,可以用于隐藏房间的结构和设备。可以使用Ceiling类来创建、修改和删除天花板。下面是一个创建天花板的示例:

// 创建一个新的天花板Ceiling ceiling = doc.Create.NewCeiling(level, profile, ceilingType);

其中,level是天花板所在的标高,profile是一个CurveArray对象,表示天花板的边界,ceilingType是天花板类型。

屋顶(Roof):在Revit中,屋顶是由一个或多个边界定义的斜面构件。可以使用FootPrintRoof类或ExtrusionRoof类来创建、修改和删除屋顶。下面是一个创建屋顶的示例:

// 创建一个新的足迹屋顶FootPrintRoof roof = doc.Create.NewFootPrintRoof(profile, roofType, level, false);

其中,profile是一个CurveArray对象,表示屋顶的边界,roofType是屋顶类型,level是屋顶所在的标高。

洞口(Opening):在Revit中,洞口可以用于在墙、楼板等构件中创建一个洞,以便放置门、窗等构件。可以使用Opening类来创建、修改和删除洞口。下面是一个创建洞口的示例:

// 创建一个新的洞口Opening opening = doc.Create.NewOpening(host, plane, true);

其中,host是包含洞口的构件,plane是洞口所在的平面。

这些示例只是Revit API中创建这些构件的一种方法,可以根据自己的需要选择不同的方法。另外,创建这些构件之前,需要先定义它们的类型、标高等信息。

代码

using Autodesk.Revit.DB.Structure;using System.Collections.Generic;namespace Autodesk.Revit.DB{public class Wall : HostObject{public CurtainGrid CurtainGrid {get; }public WallType WallType {get; set; }public double Width {get; }public StructuralWallUsage StructuralUsage {get; set; }public bool Flipped {get; }public bool IsStackedWall {get; }public bool IsStackedWallMember {get; }public ElementId StackedWallOwnerId {get; }public WallCrossSection CrossSection {get; set; }public XYZ Orientation {get; }public ElementId SketchId {get; }public static Wall Create(Document document, Curve curve, ElementId levelId, bool structural);public static Wall Create(Document document, IList<Curve> profile, bool structural);public static Wall Create(Document document, IList<Curve> profile, ElementId wallTypeId, ElementId levelId, bool structural);public static Wall Create(Document document, IList<Curve> profile, ElementId wallTypeId, ElementId levelId, bool structural, XYZ normal);public static Wall Create(Document document, Curve curve, ElementId wallTypeId, ElementId levelId, double height, double offset, bool flip, bool structural);public bool CanHaveProfileSketch();public Sketch CreateProfileSketch();public void Flip();public IList<ElementId> GetStackedWallMemberIds();public bool IsWallCrossSectionValid(WallCrossSection wallCrossSection);public void RemoveProfileSketch();}}

//============代码片段4-7 创建默认墙============ElementId levelId = new ElementId(311);using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create wall");Wall wall = Wall.Create(RevitDoc, Line.CreateBound(new XYZ(0, 0, 0), new XYZ(100, 0, 0)), levelId, false);mit();}//============代码片段4-8 创建梯形墙============IList<Curve> curves = new List<Curve>();curves.Add(Line.CreateBound(new XYZ(100, 20, 0), new XYZ(100, -20, 0)));curves.Add(Line.CreateBound(new XYZ(100, -20, 0), new XYZ(100, -10, 10)));curves.Add(Line.CreateBound(new XYZ(100, -10, 10), new XYZ(100, 10, 10)));curves.Add(Line.CreateBound(new XYZ(100, 10, 5), new XYZ(100, 20, 0)));using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create wall");Wall wall = Wall.Create(RevitDoc, curves, false);mit();}//============代码片段4-9 创建正反两面墙============ElementId levelId = new ElementId(311);ElementId wallTypeId = new ElementId(397);IList<Curve> curves = new List<Curve>();// 创建第一面墙XYZ[] vertexes = new XYZ[] {new XYZ(0, 0, 0), new XYZ(0, 100, 0), new XYZ(0, 0, 100) };for (int ii = 0; ii < vertexes.Length; ii++){if (ii != vertexes.Length - 1)curves.Add(Line.CreateBound(vertexes[ii], vertexes[ii + 1]));elsecurves.Add(Line.CreateBound(vertexes[ii], vertexes[0]));}Wall wall = null;using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create wall 1");wall = Wall.Create(RevitDoc, curves, wallTypeId, levelId, false, new XYZ(-1, 0, 0));mit();}// 创建第二面墙,面朝向相反curves.Clear();vertexes = new XYZ[] {new XYZ(0, 0, 100), new XYZ(0, 100, 100), new XYZ(0, 100, 0) };for (int ii = 0; ii < vertexes.Length; ii++){if (ii != vertexes.Length - 1)curves.Add(Line.CreateBound(vertexes[ii], vertexes[ii + 1]));elsecurves.Add(Line.CreateBound(vertexes[ii], vertexes[0]));}using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create wall 2");wall = Wall.Create(RevitDoc, curves, wallTypeId, levelId, false, new XYZ(1, 0, 0));mit();}//============代码片段4-10 创建墙,并设置高度,偏移和是否翻转============ElementId levelId = new ElementId(311);ElementId wallTypeId = new ElementId(397);using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create wall");Wall wall = Wall.Create(RevitDoc, Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 100, 0)), wallTypeId, levelId, 200, 300, true, false);mit();}//============代码片段4-11 创建三角形墙============CurveArray curveArray = new CurveArray();curveArray.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(100, 0, 0)));curveArray.Append(Line.CreateBound(new XYZ(100, 0, 0), new XYZ(0, 100, 0)));curveArray.Append(Line.CreateBound(new XYZ(0, 100, 0), new XYZ(0, 0, 0)));using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create floor");Floor floor = RevitDoc.Create.NewFloor(curveArray, false);mit();}//============代码片段4-12 创建屋顶============using (Transaction transaction = new Transaction(RevitDoc)){View view = RevitDoc.ActiveView;//先创建一个参照平面XYZ bubbleEnd = new XYZ(0, 0, 0);XYZ freeEnd = new XYZ(0, 100, 0);XYZ thirdPnt = new XYZ(0, 0, 100);transaction.Start("Create reference plane");ReferencePlane plane =RevitDoc.Create.NewReferencePlane2(bubbleEnd, freeEnd, thirdPnt, view);mit();//创建屋顶前准备参数Level level = RevitDoc.GetElement(new ElementId(311)) as Level;RoofType roofType = RevitDoc.GetElement(new ElementId(335)) as RoofType;CurveArray curveArray = new CurveArray();curveArray.Append(Line.CreateBound(new XYZ(0, 0, 50), new XYZ(0, 50, 100)));curveArray.Append(Line.CreateBound(new XYZ(0, 50, 100), new XYZ(0, 100, 50)));//创建屋顶transaction.Start("Create roof");RevitDoc.Create.NewExtrusionRoof(curveArray, plane, level, roofType, 10, 200);mit();}//============代码片段4-13 创建带洞口屋顶============using (Transaction transaction = new Transaction(RevitDoc)){//创建屋顶前准备参数Level level = RevitDoc.GetElement(new ElementId(311)) as Level;RoofType roofType = RevitDoc.GetElement(new ElementId(335)) as RoofType;CurveArray curveArray = new CurveArray();//屋顶外边框curveArray.Append(Line.CreateBound(new XYZ(0, 0, 0), new XYZ(30, 0, 0)));curveArray.Append(Line.CreateBound(new XYZ(30, 0, 0), new XYZ(30, 30, 0)));curveArray.Append(Line.CreateBound(new XYZ(30, 30, 0), new XYZ(0, 30, 0)));curveArray.Append(Line.CreateBound(new XYZ(0, 30, 0), new XYZ(0, 0, 0)));//在中间添加洞口curveArray.Append(Line.CreateBound(new XYZ(5, 5, 0), new XYZ(5, 15, 0)));curveArray.Append(Line.CreateBound(new XYZ(5, 15, 0), new XYZ(15, 5, 0)));curveArray.Append(Line.CreateBound(new XYZ(15, 5, 0), new XYZ(5, 5, 0)));//创建屋顶transaction.Start("Create roof");ModelCurveArray modelCurveArray = new ModelCurveArray();FootPrintRoof roof =RevitDoc.Create.NewFootPrintRoof(curveArray, level, roofType, out modelCurveArray);//设置屋顶坡度ModelCurve curve1 = modelCurveArray.get_Item(0);ModelCurve curve3 = modelCurveArray.get_Item(2);roof.set_DefinesSlope(curve1, true);roof.set_SlopeAngle(curve1, 0.5);roof.set_DefinesSlope(curve3, true);roof.set_SlopeAngle(curve3, 1.6);mit();}//============代码片段4-14 创建独立实例============// place a furniture at (0,0,0)FamilySymbol familySymbol = RevitDoc.GetElement(new ElementId(99774)) as FamilySymbol;using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create standard-alone instance");FamilyInstance familyInstance = m_creation.NewFamilyInstance(new XYZ(0, 0, 0), familySymbol, StructuralType.NonStructural);mit();Trace.WriteLine(familyInstance.Id);}//============代码片段4-15 墙上创建门============// 在墙上创建一扇门FamilySymbol familySymbol = RevitDoc.GetElement(new ElementId(49480)) as FamilySymbol;Level level = RevitDoc.GetElement(new ElementId(30)) as Level;Wall hostWall = RevitDoc.GetElement(new ElementId(180736)) as Wall;using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create standard-alone instance");FamilyInstance familyInstance = m_creation.NewFamilyInstance(new XYZ(0, 0, 0), familySymbol, hostWall, level, StructuralType.NonStructural);mit();Trace.WriteLine(familyInstance.Id);}//============代码片段4-16 创建柱子============// place a column at (0,0,0),FamilySymbol familySymbol = RevitDoc.GetElement(new ElementId(52557)) as FamilySymbol;Level level = RevitDoc.GetElement(new ElementId(331)) as Level;using (Transaction transaction = new Transaction(RevitDoc)){transaction.Start("Create a level based instance");FamilyInstance familyInstance = m_creation.NewFamilyInstance(new XYZ(0, 0, 0), familySymbol, level, StructuralType.NonStructural);mit();Trace.WriteLine(familyInstance.Id);}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。