Revit API之在墙或者屋顶上开洞口【比目鱼原创】
2017-12-07 17:03
232 查看
在墙上开洞口的代码可以参考这个:
在屋顶创建洞口的代码参考这个:
=========【更多高级应用请关注公众号】========
===================================
Wall wall = GetElement<Wall>(185520); LocationCurve locationCurve = wall.Location as LocationCurve; Line location = locationCurve.Curve as Line; XYZ startPoint = location.get_EndPoint(0); XYZ endPoint = location.get_EndPoint(1); Parameter wallHeightParameter = wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM); double wallHeight = wallHeightParameter.AsDouble(); XYZ delta = (endPoint - startPoint + new XYZ(0, 0, wallHeight)) / 3; using (Transaction transaction = new Transaction(RevitDoc)) { transaction.Start("Create Opening on wall"); Opening opening = RevitDoc.Create.NewOpening(wall, startPoint + delta, startPoint + delta * 2); transaction.Commit(); }
在屋顶创建洞口的代码参考这个:
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); transaction.Commit(); }
=========【更多高级应用请关注公众号】========
===================================
相关文章推荐
- Revit API之如何创建梯形墙及带正反面的墙【比目鱼原创】
- Revit二次开发之关于外部命令IExternalCommand【比目鱼原创】
- Revit二次开发之Revit事务模式(TransactionMode)【比目鱼原创】
- Revit二次开发之如何选取Revit元素【比目鱼原创】
- RevitAPI之关于Room、Area、Tag【比目鱼原创】
- (原创)怎样在word,windows live writer,或者博客(如网易博客,新浪博客)中设置代码语法高亮和底纹
- Revit二次开发之快速过滤与慢速过滤【比目鱼原创】
- Revit API之Document与UIDocument的深入理解【比目鱼原创】
- Revit二次开发之获取参数绑定的类别【比目鱼原创】
- RevitAPI之创建文字和注释【比目鱼原创】
- 《人品免费》第五章 人品=好、优秀、卓越、或者崇高?(原创首发)
- 【原创】java applet Clock + Timer时钟或者电子钟也行,计时功能
- archivelog下不需要热备也能完全恢复损坏或者被删除的datafile(原创)
- RevitAPI之创建房间方法的介绍【比目鱼原创】
- 试验之——冷备份或者是热备份,shutdown immediate 后可以恢复所有的datafile(原创)
- Revit二次开发之Journal日志文档【比目鱼原创】
- RevitAPI之创建一个面积【比目鱼原创】
- [原创]通过动态Sql语句,一次性彻底删除或者修改SBO的某个字段对应内容的信息
- 【原创】loadrunner12.53 录制脚本时 打不开网页或者打开网页慢?
- [原创]用脚本控制Select的展开与折叠,或者说是下拉。