How Find Longest Wall in Rooms

How Find Longest Wall in Rooms

csvFC98Y
Participant Participant
488 Views
4 Replies
Message 1 of 5

How Find Longest Wall in Rooms

csvFC98Y
Participant
Participant

Hello !

Best regats to Guru, who share information as knowledge. 🙂

Very_beginer unit in C#, please support:

Need find longest wall in each room. find only longest in progect. what do wrong for my goal ?

 

My try gets only in Double format, need certainly Curve or Line

 

var options = new SpatialElementBoundaryOptions();
Double maxCurve = rooms.SelectMany(item => item.GetBoundarySegments(options)).SelectMany(item => item).Select(
item => item.GetCurve()).Max(item => item.Length) * 304.8;

 

 

 

Accepted solutions (1)
489 Views
4 Replies
Replies (4)
Message 2 of 5

Ali.sadeghi.h1994
Enthusiast
Enthusiast

Hi.

In my opinion, one way is to create a Filter to collect all the walls and narrow down elements to walls and put them in a list. Then, use   BuiltInParameter.CURVE_ELEM_LENGTH   of each wall in a   for loop  and compare the  length of walls with If Statement in order to find longest wall and pass it to a null reference. So, you can use this reference element everywhere you want.

Message 3 of 5

csvFC98Y
Participant
Participant

@Ali.sadeghi.h1994 

Lenght of walls curves i can take easy, but how collect walls by room belonging ?

That's why i went by BoundarySegment way. It takes boundarySegment like a Curves, but i cant take their lenght.

0 Likes
Message 4 of 5

longt61
Advocate
Advocate

I believe your problem is that you don't know which wall belong to your current room. using boundary segment does not guarantee finding correct wall due to 2 reasons:

1. It depends on the whether the walls are set to "RoomBounding" or not. 

2. There are other elements can be room bounding such as room separators. Thus, using room boundary can only find the longest BOUNDARY SEMGEMNT, not longest wall.

As for solution, I think you can use a bounding box intersection filter for the given room to find all relevant walls then just find the longest wall among them. You can also query all walls in project and get their Ids for the bounding box intersection filter to improve performance.

This solution has 1 drawback is that you need to tailor your code more to find exact relevant walls for your room in some edgy cases such as:

1. a wall belongs to 2 rooms,

2. 2 walls parallel to each other and each one can belong to a different room, or they can belong to the same room. This can happen when Revit designers try to user multiple parallel walls to represent a compound wall with many layers. Why? They say this trick gives them some advantage when splitting each layer separately and or scheduling the material and volume etc..etc..

Hope this helps.

Message 5 of 5

csvFC98Y
Participant
Participant
Accepted solution

Thank for every one who help.

As total: i find rooms => Get BoundarySegments => get Id of segment => Get Elements by Id => filter only wall => getLocationCurve => sort by Length => get last in item. 

Its give good result for my goals.

Hello   to   Jeremy Tammik   😉

0 Likes