RevitiAPI: NewExtrusion throws ArgumentException: One of the conditions for the inputs was not satisfied

中文链接

By Aaron Lu

Sometimes calling Document.FamilyCreate.NewExtrusion will throw:

Autodesk.Revit.Exceptions.ArgumentException: One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.

This is probably caused by the profile and normal of sketch plane is not perpendicular.

For example:

// 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);

This will throw, and notice that the normal of SketchPlane is the same as Z axis, but the profile is perpendicular to Y axis,

So the correct code of creating SketchPlane should be something like this:

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

 


Comments

One response to “RevitiAPI: NewExtrusion throws ArgumentException: One of the conditions for the inputs was not satisfied”

  1. I’d like to thank the author for writing such an insightful and informative blog post about revit api newextrusion that is not just useful to the readers but also revealing.

Leave a Reply