Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Room boundary to baseboards: group up the connected line segments

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
MiguelGT17
793 Views, 12 Replies

Room boundary to baseboards: group up the connected line segments

Greetings to everyone, I've manage to get the room boundary and place direct shapes as solids

MiguelGT17_0-1669335751970.png

 

However the arch team wants to use another element so it can be editable manually after running the add-in and close those gaps at the corners. Therefore, we came up with the idea of using railings.

Now the problem is to transform the direct shape data to railings.

 

After getting the direct shape bottom lines, I came up with the surprised that for some wall the lines are not arranged consecutively in a list:

MiguelGT17_2-1669336239186.png

 

 

 

Havin the data before, I wish to group them up like in the following picture, so afterwards I can manage to create curveloops for my railings 

MiguelGT17_1-1669336066103.png

 

Is there any algorithm do you recommend to address this matter? the exercise can become more tedious for other rooms:

  • Hallway:

MiguelGT17_4-1669336356056.png

This is what I've been working on. It's the 4 time I'm working on a new approach so let me know if sounds good or have some suggestions:

MiguelGT17_5-1669337555646.png

  • Perhaps if I query the index neighbour for each line,  I keep the pair key values in a dictionary, then I can do a first loop to find if there is another line that at least has 1 same number/neighbor for the current line

 

  • Then, I might want to accumulate all the adjacent values in the first loop

 

  • For a second loop, I can iterate between all of them in case I miss a line that belong to the current group
  • (for instance, line number 14 must belong to group "0-14-2-1-13" but when I iterate over line 1 as a first loop, It will never identify line 14 because line1 neighbors follow as "1,2,13" although line14 has "0,2,14". However, in a 2° loop, all the values stored line1,line2 and line 13 will be "1,2,13" and line 14 has the 2 index as an adjacent value so it will be included this time.

 

  • I can continue to loop again until there are no other lines with at least 1 adjacent value that match the ones stored till the previous loop.

if everything goes right, then I can check out @jeremy_tammik  blog to order lines consecutively for each group so I can create the curveloops

All the best,

Miguel G.

 

 

 

by the way, direct shape was helpful to get room boundaries as the solid boolean operations allows us to avoid placing direct shape solids behind cabinets, wall openings, bathrooms and kitchen fixtures, and other appliances that we wish to susbtract their solid from the direct shape baseboard.

12 REPLIES 12
Message 2 of 13
jeremy_tammik
in reply to: MiguelGT17

This is an interesting task from computational geometry and has very little to do with the Revit API. I would suggest searching for more abstract and generic algorithms, e.g.:

 

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 13
RPTHOMAS108
in reply to: MiguelGT17

There are many ways to do this it is quite common for curveloops that you need to add the lines in order and direction of the first curve.

 

One possibility is you collect up all the line end points, when you have only one XYZ at a location you know it is a free end (other internal locations should have two XYZ points). Once you have the free ends you know where to start. You then just get the curve that has that end point and find the next curve matching the opposite end. You may need to reverse the curve depending on the matching end you find. A while loop is required for this process i.e. when you find no more curves with ends matching the current set you complete the set and start the next set. I usually use what I would term a reduction set i.e. for each iteration of the while loop you take the first item from the reduction set until you no longer have any items left to match or start a new set. In truth you don't even need to initially know the free ends because you are either placing the curve with matching end at one of free ends in the set: List<T>.Insert(0) or List<T>.Insert(Count-1). 

 

Wall sweep seems better option than railing, you may not even need to do the above task then i.e. wall sweeps can be defined in the type with a fixed profile or added to the instance, you decide which side of the wall they are on, and they respect doors and windows (with a default cut-back). If the sweep is hosted on the instance then you can also adjust the ends in the UI to drag them back creating discontinuities, I'm not sure that functionality exists within the API.

 

221125.png

Message 4 of 13
MiguelGT17
in reply to: jeremy_tammik

Thanks for the guidance Jeremy, the last URL since the way to go!

Message 5 of 13
MiguelGT17
in reply to: RPTHOMAS108

We have considered using wall sweeps, but there were many constraints: if a wall surrounds more than 1 room then there is no easy way to control the constraint for the wall sweep:

MiguelGT17_0-1669489574199.png

therefore we will need to manually make some adjustments which doesnt sound very attractive to the team.

 

 

Thanks Thomas for sharing thoughts on building an algorithm. I was using operation between points but somehow the points were changing. e.g. for a 1° loop the middle point for line at index 1 was (0,1,0) then for a 2° loop the middle point turn out to be (2,2,0). It was crazy. I'm giving another try using just indexes.

 

Message 6 of 13
BenoitE&A
in reply to: MiguelGT17

Hey,

I'm wondering what you are trying to do. Creating railings is tedious if the aim is only to work on geometry.

We've done a lot of Geometry of this type. I guess you retrieve the geometry of the room with GetBoundarySegments.

I have never crossed a case where the arrangement of the BoundarySegments are not consecutive (and I've seen tens and my algos thousands) so I'm really curious (and skeptical) about that. 

We made the choice to compute geometry using both internal and external tools (NetTopologySuite) because we needed to have boolean algebra and specific tools to work on Room boundaries, which we found tedious using XYZ.

Anyway I'm curious...


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 7 of 13
jeremy_tammik
in reply to: BenoitE&A

https://nettopologysuite.github.io/NetTopologySuite/index.html

  

... sounds very interesting indeed! Thank you for pointing it out. Would you like to share some examples of using it in combination with the Revit API? This might make a brilliant article for The Building Coder and motivate many others to widen their horizon working with 2D geometry in the Revit API.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 8 of 13
MiguelGT17
in reply to: BenoitE&A

Basically I'm trying to place baseboards and I managed to do it by creating direct shape geometries. The drawbacks are that this element is not editable, I can not set the baseboard profile at all and I will need to work on another algorithm to close the gap at the corners:

 

MiguelGT17_1-1669638002987.png

railings solve this problem so the task turns out to be transforming direct shapes into railings

 

NetTopologySuite is new to me, I will check it out, thanks for bringing it up

 

 

 

 

Message 9 of 13
BenoitE&A
in reply to: jeremy_tammik

Ahah we did many things:

- automatically place furniture in housing (from beds, the easiest, to TV set, kitchen appliances and bathroom stuff)

- automatically place electric fixtures in housing (lights, switches, plugs) or HVAC elements (ventilation, heating)

- automatically recognize housing units and name Rooms from their caracteristics

The first 2 examples use mainly simple geometric rules while the last makes an extensive use of boolean 2D operations.

And we are currently working on connecting 2 elements with for ex. cold water pipe, which is not that easy (more geometry there ;))


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 10 of 13
jeremy_tammik
in reply to: MiguelGT17

Just looking at this image, an easy solution to close the gap would be to declare the baseboard to be a wall and set its join type to miter. After the wall has finished generating, you could grab its geometry and replace it by a direct shape. However, calculating your own miter join in the corners to close the gaps would probably be more direct and efficient, and cause less problematic side effects. I wish you lots of fun and success exploring NetTopologySuite and look forward to hearing whether and how exactly you end up using that.

  

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 11 of 13
RPTHOMAS108
in reply to: MiguelGT17

Yes you are right in the UI you can have multiple wall sweeps on the same wall and change their extents to organise them. For example, I could easily fix that issue you show using the UI but I've not seen similar functionality in the API regarding adjusting extents.

 

If you were to ask the average non-API user what they would expect that type of object to be I think they would say wall sweep. You have to be mindful of scheduling etc. when you make these category choices.

 

But I see your point.

 

Also consider that your issue with the direct shapes was that they could not be edited but that is down to your add-in. For example, if your direct shapes were updated to follow a model line then there is the functionality to edit them (could perhaps even be achieved via IUpdater).

Message 12 of 13
MiguelGT17
in reply to: jeremy_tammik

Thank you so much @jeremy_tammik making use of wall joins solve the issue for now. As a long term goal, I might need to crack down that previously algorithm to place railings as I find hard to modify the wall section profile using and in case the team wish to have baseboards with a specific profile, railings ease this matter.

All the best,

Miguel G.

Message 13 of 13
MiguelGT17
in reply to: RPTHOMAS108

That's correct, I might need to create a parameter that helps to identify walls as baseboards to have them in a schedule.

I'm looking for exploring the IUpdater for upcoming tasks, I didnt know I could link a model line with a direct shape. That would be awesome to see it working. Thanks Thomas for the hints!

All the best,

Miguel G.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Rail Community