- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to generate curve loops from boundary points of TopoSurfaces.
I am using for loop that runs through the points and creates curves for each pair and then adds to a List of curves, which is then used to create curveloop.
My end purpose is to generate loft geometry from these curve loops.
The problem is that the last curve of my curveloop intersects with the first curve which the API doesnt allow for loft creation, and if i remove this last curve, then the loft geometry created is not a solid but rather an open shell.
So how can i achieve these closed curveloops without creating any intersection. Any help would be appreciated
Here is my code that explains my description further:
IList<XYZ> bounding_pts1 = topo1.GetBoundaryPoints();
List<Curve> curves1 = new List<Curve>();
// Implement a For loop to create curves from the boundary
//points of topography
for (int i = 0; i < bounding_pts1.Count; ++i)
{
if (i < bounding_pts1.Count - 1)
{
// Create lines and add to curves list
Line line = Line.CreateBound(bounding_pts1[i], bounding_pts1[i + 1]);
//Append points to CurveLoop
curves1.Add(line);
}
else if (i == bounding_pts1.Count - 1)
{
// Create lines and add to curves list
Line line = Line.CreateBound(bounding_pts1[i], bounding_pts1[0]);
//Append points to CurveLoop
curves1.Add(line);
}
}
//Create line connecting start and end point of topography bound points and adding it to curves collection
// check intersection/ Overlap b/w first and last curve in curves list
IntersectionResultArray resultArray1 = new IntersectionResultArray();
int lastcurveidx1 = curves1.Count - 1;
var check_intersect1 = curves1[0].Intersect(curves1[lastcurveidx1], out resultArray1);
XYZ intersection_point1 = new XYZ();
if (check_intersect1 == SetComparisonResult.Overlap)
{
//remove the last curve from curves2 list and get XYZ position of the intersection/overlap
curves1.RemoveAt(lastcurveidx1);
intersection_point1 = resultArray1.get_Item(0).XYZPoint;
//Now create a new curve which ends at the intersection point and add it to curves2 list
int lastpointidx1 = bounding_pts1.Count - 1;
Line last_line1 = Line.CreateBound(bounding_pts1[lastpointidx1], intersection_point1);
curves1.Add(last_line1);
}
// create First curve loop from list of curves i.e a polygon
CurveLoop curveLoop1 = CurveLoop.Create(curves1);
// now get second topography and perform the same procedure as above
Selection sel2 = uiapp.ActiveUIDocument.Selection;
TopographySurface topo2 = doc.GetElement(sel2.PickObject(ObjectType.Element)) as TopographySurface;
IList<XYZ> bounding_pts2 = topo2.GetBoundaryPoints();
List<Curve> curves2 = new List<Curve>();
for (int i = 0; i < bounding_pts2.Count ; ++i)
{
if(i < bounding_pts2.Count - 1)
{
// Create lines and add to curves list
Line line = Line.CreateBound(bounding_pts2[i], bounding_pts2[i + 1]);
//Append points to CurveLoop
curves2.Add(line);
}
else if (i == bounding_pts2.Count - 1)
{
Line line = Line.CreateBound(bounding_pts2[i], bounding_pts2[0]);
//Append points to CurveLoop
curves2.Add(line);
}
}
//Create line connecting start and end point of topography bound points and adding it to curves collec
// check intersection/ Overlap b/w first and last curve in curves list
IntersectionResultArray resultArray = new IntersectionResultArray();
int lastcurveidx2 = curves2.Count - 1;
var check_intersect = curves2[0].Intersect(curves2[lastcurveidx2], out resultArray);
XYZ intersection_point = new XYZ();
if (check_intersect == SetComparisonResult.Overlap)
{
//remove the last curve from curves2 list and get XYZ position of the intersection/overlap
curves2.RemoveAt(lastcurveidx2);
intersection_point = resultArray.get_Item(0).XYZPoint;
//Now create a new curve which ends at the intersection point and add it to curves2 list
int lastpointidx2 = bounding_pts2.Count - 1;
Line last_line2 = Line.CreateBound(bounding_pts2[lastpointidx2], intersection_point);
curves2.Add(last_line2);
}
// create curve loop from list of curves i.e a polygon
CurveLoop curveLoop2 = CurveLoop.Create(curves2);
List<CurveLoop> curve_profiles = new List<CurveLoop>();
curve_profiles.Add(curveLoop1);
curve_profiles.Add(curveLoop2);
Update:
i tried taking the start point of the first curve and used it as the endpoint of the final curve to get the CurveLoop closed but i am still getting the same error
Here the code snippet:
// First check if there is an overlap/ intersection in the curveloop
if (check_intersect1 == SetComparisonResult.Overlap)
{
//remove the last curve from curves2 list and get XYZ position of the intersection/overlap
curves1.RemoveAt(lastcurveidx1);
intersection_point1 = resultArray1.get_Item(0).XYZPoint;
//Now create a new curve which ends at the intersection point and add it to curves2 list
int lastpointidx1 = bounding_pts1.Count - 1;
// get start point of first curve from the curve list
var start_pt_first_curve = curves1[0].GetEndPoint(0);
Line last_line1 = Line.CreateBound(bounding_pts1[lastpointidx1], start_pt_first_curve);
curves1.Add(last_line1);
}
// create curve loop from list of curves i.e a polygon
CurveLoop curveLoop1 = CurveLoop.Create(curves1);
Solved! Go to Solution.