Revit API之如何创建梯形墙及带正反面的墙【比目鱼原创】

创建墙的方法有五个重载。方法和用途如下表:

方法

用途

public static Wall Create(Document document, IList<Curve> profile, bool structural);

给定曲线和标高,使用默认墙类型创建墙

        public static Wall Create(Document document, Curve curve, ElementId levelId, 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);

与上面类似,增加一个参数normal可以指定墙的朝向

        public static Wall Create(Document document, Curve curve, ElementId wallTypeId, ElementId levelId, double height, double offset, bool flip, bool structural);

创建墙,并设置墙的高度(height参数),底部偏移 (offset参数),是否翻转(flip)

 

一)、创建梯形墙

WallCreate(Document document,IList<Curve〉profile,bool structural) 这个函数,给定

墙的曲线形状,使用默认墙类型创建墙


IList<Curve>curves = new List<Curve>();
curves.Add(Line.CreateBound(newXYZ(100, 20, 0), new XYZ(100, -20, 0)));
curves.Add(Line.CreateBound(newXYZ(100, -20, 0), new XYZ(100, -10, 10)));
curves.Add(Line.CreateBound(newXYZ(100, -10, 10), new XYZ(100, 10, 10)));
curves.Add(Line.CreateBound(newXYZ(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);
   transaction.Commit();
}

注意:

•曲线形状是墙的正面,即创建的是一面墙,而不是创建一系列的墙。

•形状是必须闭合的,否则抛异常,创建失败。

•无法创建斜的墙。

 

二)、创建带正反面的墙

public static Wall Create(Documentdocument, IList<Curve> profile, ElementId wallTypeId, ElementId levelId,bool structural, XYZ normal);

参数 normal可以指定墙的朝向。如果创建的墙的朝向不符合要求,可以使用Wall.Flip()实例方法来调整墙的朝向。

 

ElementId levelId = new ElementId(311);
ElementId wallTypeId = new ElementId(397);
IList<Curve> curves = newList<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]));
  else
     curves.Add(Line.CreateBound(vertexes[ii], vertexes[0]));
}
Wall wall = null;
using (Transaction transaction = newTransaction(RevitDoc))
{
  transaction.Start("Create wall 1");
  wall = Wall.Create(RevitDoc, curves, wallTypeId, levelId, false, newXYZ(-1, 0, 0));
  transaction.Commit();
}
 
// 创建第二面墙,朝向相反
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]));
  else
     curves.Add(Line.CreateBound(vertexes[ii], vertexes[0]));
}
using (Transaction transaction = newTransaction(RevitDoc))
{
  transaction.Start("Create wall 2");
  wall = Wall.Create(RevitDoc, curves, wallTypeId, levelId, false, newXYZ(1, 0, 0));
   transaction.Commit();
}

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


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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值