RevitAPI: 调用NewExtrusion的时候抛出异常 One of the conditions for the inputs was not satisfied

当调用Document.FamilyCreate.NewExtrusion的时候,可能会抛出下面的异常

Autodesk.Revit.Exceptions.ArgumentException: One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.
这个很有可能是因为您传入的profile和normal不垂直,也就是形状和拉伸方向不垂直。

例如自己的代码可能是这么写的:

// Create a rectangle profile
CurveArrArray profile = new CurveArrArray();
CurveArray ca = new CurveArray();
XYZ[] points = new XYZ[] {
    new XYZ(10, 0, 0),
    new XYZ(20, 0, 0),
    new XYZ(20, 0, 10),
    new XYZ(10, 0, 10)
};
for (int ii = 0; ii < points.Length; ii++)
{
    var point = points[ii];
    var point2 = points[ii == points.Length - 1 ? 0 : ii + 1];
    ca.Append(Line.CreateBound(point, point2));
}
profile.Append(ca);

// create the plane normal is perpendicular with profile
SketchPlane sketchplane = SketchPlane.Create(doc, 
    new Plane(XYZ.BasisZ, XYZ.Zero));
Extrusion solid = doc.FamilyCreate.NewExtrusion(
    true, profile, sketchplane, 20);

实际上注意到SketchPlane的normal是向上的也就是和Z轴垂直,而profile和Y轴垂直,

所以,创建SketchPlane的代码应该是这样的:

SketchPlane sketchplane = SketchPlane.Create(doc, 
    new Plane(XYZ.BasisY, XYZ.Zero));


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值