Boundary Segments Issue

Boundary Segments Issue

juanquis_avila
Contributor Contributor
2,017 Views
11 Replies
Message 1 of 12

Boundary Segments Issue

juanquis_avila
Contributor
Contributor

Hello devs,

 

I've got a question concerning segment that bound a space. In theory, for just a single room, I should have 4 segments per room but in most cases I've got more than 4 segments and i guess this happens because there are some other elements which divide those segments (like a wall). Below you can find a picture with more information.

 

 

image.png

 

For example. For this particular case I'm expecting to have 4 segment but im getting 6 instead due the perpendicular walls which are dividing the segment.

 

My question is: is there any way to get only the 4 segments? What I'm trying to accomplish is to get the four corners of a room!

 

Thank you guys. you are all AWESOME 😄 

 

 

0 Likes
Accepted solutions (1)
2,018 Views
11 Replies
Replies (11)
Message 2 of 12

jeremytammik
Autodesk
Autodesk

You assumption is correct.

 

The separate segments stem from different elements.

 

Note that you can query each boundary segment for the element that is producing it using its ElementId property:

 

https://apidocs.co/apps/revit/2019/eaf7d628-d9c2-80a3-2fd7-00013bab1377.htm

 

> Retrieve the id of the element that produces this boundary segment. If the segment is created from an element in a link, this is the id of the RevitLinkInstance.
 
To obtain just four segments for your square room, you can perform some geometric analysis to combine collinear segments into longer pieces.
 
If all you need are the four corners, you can (much more) easily determine those by stepping through all the segments (optionally tessellated, if they may be curved) and determine their max and min X, Y and Z coordinates.
  

Cheers,

  

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 12

juanquis_avila
Contributor
Contributor

Hello Jeremy,

 

thank you so much for your answer...

 

yeah i thought about putting together the segments which have got the same element, that might be a solution.

 

concerning the corners, when you say max and min XYZ coordinates you mean the GetEndPoint() method, dont you? if you do, then i would  have a problem with the stem segments. based on the image on the right wall you can see two segments, light blue and dark blue. It means that for light blue, one point would be the corner but the other point is touching the adjacent point at the dark blue segment. For that condition, it would be pretty hard to tell the program which point is located at the corner. 

 

If i assure to have only four segments bounding the room would be easier to get the corners.

 

Greeting,

Juan Avila

0 Likes
Message 4 of 12

BenoitE&A
Collaborator
Collaborator
Accepted solution

Hi Juan,

Just a clarification :

Most of the time having 2 BoundarySegment which are the same direction one after the other means that you have 2 different walls behind them (for example one with insulation and the other without). 

For your question of retrieving the corners / simplifying your contour, I would rather try to simplify than retrieve the corners. Here is a solution you could implement :

- for consecutive BoundarySegments, check their directions (if your BoundarySegment's Curve is a Line, you can use the Line's Direction). If the directions are the same, then you can simplify the 2 curves by mutualizing them (for example create a new Line beginning with the first line's end and ending in the other's end).

- be careful of small length Lines which can connect parallel BoundarySegments (it happens often). 

- depending on your algo, use recursion.

Have fun !

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 5 of 12

juanquis_avila
Contributor
Contributor

Dear Benoit,

 

thank you very much for your answer... i will check that out and tell you if it works for me.

 

cheers and take care.

0 Likes
Message 6 of 12

juanquis_avila
Contributor
Contributor

Guys. I might have solved this segment problem! Let me know if anyone is interested to talk about it 😄 

0 Likes
Message 7 of 12

jeremytammik
Autodesk
Autodesk

Congratulations!

 

Yes, sure, please tell us more.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 12

olisehemeka_chukwumaC6U52
Observer
Observer

Hey juanqis,

Do you still have the answer to this problem?

Message 9 of 12

BenoitE&A
Collaborator
Collaborator

Funny to get this very old post alive.

I'd change my answer from the time and say:

- sometimes the BoundarySegment list is holed (around windows and at the end of walls ending in the middle of the Room). So you have to close the List, practically we add another Segment to the List.

- check either Douglas Peucker or Visvaligham algorithms, easy to implement and very useful. At least that's what we use and these work fine for us.

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 10 of 12

juanquis_avila
Contributor
Contributor

Do you have an approach in mind?

0 Likes
Message 11 of 12

jeremy_tammik
Alumni
Alumni

Thank you for the useful pointers and advice! I shared them on the blog:

  

https://thebuildingcoder.typepad.com/blog/2023/02/geometry-options-and-clean-simple-curves.html#2

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 12 of 12

juanquis_avila
Contributor
Contributor

Thanks for sharing @jeremy_tammik The algortihms you have provided are great. Thanks