- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This might be a stupid question, so correct me if I'm completely off.
I'm trying to leverage the .centroid property of the PolyLoop class, so I can find the center of my L-shaped rooms, but I can't figure out how to get my BoundarySegments to polyloops.
I'm currently getting the roomBoundarySegment of the room and converting them into polylines in a foreach loop.
public XYZ GetRoomCentroid(Room room)
{
IList<IList<BoundarySegment>> roomBoundarySegment = room.GetBoundarySegments(new SpatialElementBoundaryOptions());
IList<PolyLine> roomPolyLines = null;
IList<XYZ> listCoord = null;
string message = "BoundarySegment:";
foreach (IList<BoundarySegment> segmentList in roomBoundarySegment)
{
foreach (BoundarySegment segment in segmentList)
{
//Get startpoint of curve
//message += "\n Curve startpoint (" + segment.GetCurve().GetEndPoint(0).X + "," + segment.GetCurve().GetEndPoint(0).Y + "," + segment.GetCurve().GetEndPoint(0).Z + ")";
//Get endpoint of curve
//message += "\n Curve end´point (" + segment.GetCurve().GetEndPoint(1).X + "," + segment.GetCurve().GetEndPoint(1).Y + "," + segment.GetCurve().GetEndPoint(1).Z + ")";
XYZ coordinatesStart = new XYZ(segment.GetCurve().GetEndPoint(0).X, segment.GetCurve().GetEndPoint(0).Y, segment.GetCurve().GetEndPoint(0).Z);
XYZ coordinatesEnd = new XYZ(segment.GetCurve().GetEndPoint(1).X, segment.GetCurve().GetEndPoint(1).Y, segment.GetCurve().GetEndPoint(1).Z);
listCoord.Add(coordinatesStart);
listCoord.Add(coordinatesEnd);
PolyLine line = PolyLine.Create(listCoord);
roomPolyLines.Add(line);
}
}
I just can't figure out how to convert polylines, curves or anything into a Polyloop where I can call the .Centroid property.
When I look at the RevitAPI documentation it states the a Polyloop is composed of straight lines segments where each endpoint is the same is the previous startpoint - thats what I get when I'm using the BoundarySegment class as far as I understand.
Can anyone share some insight on what I'm doing wrong?
Solved! Go to Solution.