Reputation: 111
I working with a revit code to collect CurveLoops and create a loft geometry.
Creating the CurveLoops is working fine with a for loop(creates lines from points). But it creates two separate CurveLoops.
I've tried to add the for loop result to a new list(profile3). But it returns two list with one CurveLoop in it. In my case it should be two CurveLoops in one list(profile3)
CurveLoop profileLoop = new CurveLoop();
List<CurveLoop> profile3 = new List<CurveLoop>();
SolidOptions options = new SolidOptions(ElementId.InvalidElementId,
ElementId.InvalidElementId);
for (int i = 0; i < p.Count - 1; ++i)
{
// Create lines and convert points to mm
Line line = Line.CreateBound(p[i] / 304.8, p[i + 1] / 304.8);
//Append points to CurveLoop
profileLoop.Append(line);
}
//Here I want to add both created CurveLoops to list
profile3.Add(profileLoop);
//Create Loft
Solid loft = GeometryCreationUtilities.CreateLoftGeometry(profile3
, options);
Loft can't be created because it only has one curveloop in the list and it needs both created from the for loop
First CurveLoop and Second CurveLoop that should be in one list
Upvotes: 1
Views: 469
Reputation: 1025
What you are doing here is passing the same object multiple times into a list and then wonder how come all the objects in the list are the same.
You might want to look at the concept of passing by reference and the difference between reference types and value types.
Upvotes: 0
Reputation: 11
It looks like you need to add the same CurveLoop
to the list twice. So you will end up with one list with two matching elements.
I would suggest doing a second profile3.Add(profileLoop);
You aren't really creating two different CurveLoops
in that for iterator, just one. So you would need to add it twice to the list in order for your result to work.
Upvotes: 1