Revit API之在墙或者屋顶上开洞口【比目鱼原创】

在墙上开洞口的代码可以参考这个:

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(); 
}

=========【更多高级应用请关注公众号】========


===================================


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值