Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a method that takes a Sweep object and returns Solid (Swept Geometry) the purpose of this method may appear to be weired but I am doing this as a work around to get a valid solid geometry in case of sweep void in order to perform BooleanOperationUtils.ExecuteBooleanOperation. but I got this exception
"Autodesk.Revit.Exceptions.ArgumentException: 'The given attachment point don't lie in the plane of the Curve Loop.
Parameter name: pathAttachmentCrvIdx & pathAttachmentParam'"
Here is the code snippet
the exception is thrown on line 22
// main method
public static Solid GetVoidSweepSolid(Sweep ownerElement)
{
Solid voidSolid = null;
CurveLoop pathCurveLoop=null;
List<CurveLoop> pathProfile = [];
var pathCurves = GetCurveArrArrCurves(ownerElement.Path3d.AllCurveLoops).FirstOrDefault();
var endPoints = pathCurves.Select(c => (c.GetEndPoint(0), c.GetEndPoint(1))).ToList();
if (pathCurves != null)
{
pathCurveLoop = ConvertToCurveLoop(pathCurves);
}
var profileCurves = GetCurveArrArrCurves(ownerElement.ProfileSketch.Profile);
foreach (var curves in profileCurves)
{
pathProfile.Add(ConvertToCurveLoop(curves));
}
if (pathCurveLoop != null && pathProfile.Any())
{
voidSolid = GeometryCreationUtilities.CreateSweptGeometry(pathCurveLoop, 0, pathCurves[0].GetEndParameter(0), pathProfile);
}
return voidSolid;
}
// helper methods
public static List<List<Curve>> GetCurveArrArrCurves(CurveArrArray curveArrArr)
{
List<List<Curve>> curves = [];
var iter = curveArrArr.ForwardIterator();
while (iter.MoveNext())
{
List<Curve> arrCurves = [];
if (iter.Current is CurveArray curveArr)
{
var iter2 = curveArr.ForwardIterator();
while (iter2.MoveNext())
{
if (iter2.Current is Curve curve)
{
arrCurves.Add(curve);
}
}
}
if (arrCurves.Any()) curves.Add(arrCurves);
}
return curves;
}
public static CurveLoop ConvertToCurveLoop(IEnumerable<Curve> curves)
{
CurveLoop loop = null;
if (curves?.Any() == true)
{
loop = new CurveLoop();
foreach (var curve in curves)
loop.Append(curve);
}
return loop;
}
Solved! Go to Solution.