Remove Extra Points from Curve Loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey Everyone, I am tryin to remove any points inside the main rectangle of points in my curve loop. I saw one post about this already but that solution did not work for me. Can someone guide me in the proper direction to do this efficiently?
my curve loop is the shown rectangle and the points i want to remove are highlighted with an x on them.
THIS RETURNS 6 PTS NOT 4.
CurveLoop offsetCurveLoop = CurveLoop.CreateViaOffset(curveLoop, -1 * plywoodThickness, normal);
//List<XYZ> args = HelperClass.CurveLoopCornerPoints(offsetCurveLoop);
List<XYZ> args = new List<XYZ>(4);
foreach (Curve curve in offsetCurveLoop)
{
XYZ pt = curve.GetEndPoint(0);
args.Add(pt);
}
i did make a helper class to try and accomplish this but it only returns two points every time.
HELPER CLASS:
public static List<Autodesk.Revit.DB.XYZ> CurveLoopCornerPoints(this CurveLoop curveLoop)
{
List<Autodesk.Revit.DB.XYZ> points = new List<Autodesk.Revit.DB.XYZ>();
List<Autodesk.Revit.DB.XYZ> pointsToRemove = new List<Autodesk.Revit.DB.XYZ>();
foreach (Curve curve in curveLoop)
{
Autodesk.Revit.DB.XYZ pt = curve.GetEndPoint(0);
points.Add(pt);
}
var result = points;
for (int i = 0; i < points.Count; i++)
{
Autodesk.Revit.DB.XYZ firstPoint = points[i];
for (int j = 0; j < points.Count; j++)
{
if (firstPoint.ToString() != points[j].ToString())
{
Line line = Line.CreateBound(firstPoint, points[j]);
Autodesk.Revit.DB.XYZ startPoint = line.GetEndPoint(0);
Autodesk.Revit.DB.XYZ endPoint = line.GetEndPoint(1);
foreach (Autodesk.Revit.DB.XYZ xyz in points)
{
if (xyz.ToString() != startPoint.ToString() && xyz.ToString() != endPoint.ToString())
{
if (!pointsToRemove.Contains(xyz))
{
pointsToRemove.Add(xyz);
}
}
}
}
if (pointsToRemove.Count > 0)
{
foreach (Autodesk.Revit.DB.XYZ point in pointsToRemove)
{
points.Remove(point);
}
result = points;
}
}
}
return result;
}