How do I get all the outermost walls in the model?

How do I get all the outermost walls in the model?

Anonymous
Not applicable
7,351 Views
31 Replies
Message 1 of 32

How do I get all the outermost walls in the model?

Anonymous
Not applicable

I'm sorry, I'm nervous because my English is not very good~

 

How do I get all the outermost walls in the model?

 

It's like a picture shown in the picture::

12.pngthanks!

0 Likes
Accepted solutions (3)
7,352 Views
31 Replies
Replies (31)
Message 21 of 32

jeremytammik
Autodesk
Autodesk

Dear Feng Wang,

 

I am also glad about our fruitful conversation.

 

Thank you for the confirmation and sample code.

 

I like your code and will be glad to clean it up a bit for sharing on the blog, if I may.

 

A couple of comments on it:

 

 

 

  • Instead of creating objects in the model, extracting information from them, and then deleting them again, you could roll back the outermost transaction group to revert back to the original, unmodified, state. I nicknamed that the temporary transaction trick.

 

Cheers,

 

Jeremy

 



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

Message 22 of 32

Anonymous
Not applicable

Dear Jeremy,
Is this the case, please?

using(TransactionGroup group = new TransactionGroup(doc))
{ group.Start("find outermost walls"); Transaction transaction = new Transaction(doc, "createNewRoomBoundaryLines"); .......................... ........................
transaction.Commit();
// List<ElementId> elemengIds = DetermineAdjacentElementLengthsAndWallAreas(newRoom); group.RollBack();
}
0 Likes
Message 23 of 32

jeremytammik
Autodesk
Autodesk
0 Likes
Message 24 of 32

jeremytammik
Autodesk
Autodesk

Did you update the code yet?

 

Thank you!

 

 



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

0 Likes
Message 25 of 32

Anonymous
Not applicable

Dear Jeremy,

Thank you for your attention and help.

 

The appendix is the code after the modification.

Welcome to China.

 

0 Likes
Message 26 of 32

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Feng Wang,

 

Thank you for the updated code.

 

I cleaned it up a little bit more and added it to The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples

 

It lives in the new external command CmdExteriorWalls:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

The main modification I made was to use the existing walls' bounding boxes to determine the maximum model extents.

 

Retrieving the bounding box of an element is an extremely fast and efficient operation.

 

This approach also saves the need for complex handling of the wall location lines.

 

The Building Coder samples Util class even already includes an extension method `ExpandToContain` that expands a bounding box to contain another one.

 

Using that, I implemented the method GetWallBoundingBoxAroundAllWalls like this:

 

 

  /// <summary>
  /// Return a bounding box around all the 
  /// walls in the entire model; for just a
  /// building, or several buildings, this is 
  /// obviously equal to the model extents.
  /// </summary>
  static BoundingBoxXYZ GetBoundingBoxAroundAllWalls( 
    Document doc,
    View view = null )
  {
    // Default constructor creates cube from -100 to 100;
    // maybe too big, but who cares?

    BoundingBoxXYZ bb = new BoundingBoxXYZ();

    FilteredElementCollector walls
      = new FilteredElementCollector( doc )
        .OfClass( typeof( Wall ) );

    foreach( Wall wall in walls )
    {
      bb.ExpandToContain( 
        wall.get_BoundingBox( 
          view ) );
    }
    return bb;
  }

 

For the rest of the updated code, please check out the GitHub repository.

 

You can also see the modifications I made to your code step by step by looking at individual commits in the list of changes between version 2019.0.140.0 and 2019.0.140.1:

 

https://github.com/jeremytammik/the_building_coder_samples/compare/2019.0.140.0...2019.0.141.0

 

Cheers,

 

Jeremy

 



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

Message 27 of 32

Anonymous
Not applicable
0 Likes
Message 28 of 32

jeremytammik
Autodesk
Autodesk

Before I take a look at anything new, here is our discussion and solution edited and preserved for posterity:

 

http://thebuildingcoder.typepad.com/blog/2018/05/filterrule-use-and-retrieving-exterior-walls.html

 

Cheers,

 

Jeremy

 



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

Message 29 of 32

jeremytammik
Autodesk
Autodesk

Dear Feng Wang,

 

I have some news on our attempts to use the BuildingEnvelopeAnalyzer.

 

The issue REVIT-131862 [BuildingEnvelopeAnalyzer returns wrong walls -- 14230846] that I logged with our development team for this has been analysed and caused them to register a new development issue for a future release, REVIT-132477 [SUPPORT ISSUE - BuildingEnvelopeAnalyzer returns wrong walls -- 14230846].

 

Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

Best regards,

 

Jeremy

 



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

Message 30 of 32

jeremytammik
Autodesk
Autodesk

Dear Feng Wang,

 

Thank you for your patience. The engineering team repsonded to the development ticket REVIT-132477 [BuildingEnvelopeAnalyzer returns wrong walls -- 14230846, 10783979] and say:

 

I am not sure whether BuildingEnvelopAnalyzer is meant to find the outside walls. I tweaked the attached API sample to have smaller GridCellSize (say 1 ft). That resolves the issue of some walls not being found. However, all walls including interior walls are returned.

 

I also looked at the code implementation. So far I haven't found any indication that the algorithm should differentiate between interior or exterior walls. While it may be theoretically possible to enhance the algorithm, no such project has yet been discussed.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 31 of 32

m.de.vriesTH5VM
Enthusiast
Enthusiast

This algorithm to create a room around the building and let it determine its boundary walls is the most reliable and fastest solution to this particular problem of finding the exterior walls of a building. It also works better with e.g. Dutch drawing practice where compound walls are split into individual walls for its layers, making approaches that rely on 'isExternal' properties or the count of bounded rooms unreliable at best.

 

There is however one caveat that is important to keep in mind. This is essentially a 2D approach to finding boundaries as you are working with boundary lines and not planes. This appears to be a fundamental limitation of the Revit API. This is not normally a problem for this particular algorithm, but it will become one if your model has vertically stacked walls within a single level. In that case only one wall of that stack will be found, usually the one closest to the bottom of the temporary room.

There are of course work arounds to this: Determine the z-heights of each wall in the stack and create a separate room for each of those heights. This of course has to be done for every wall that falls into or crosses a particular z-height range that you are interested in, so the scan for finding all the z-heights that need to be checked separately can be time consuming for large designs.

I am guessing the BuildingEnvelopeAnalyzer needs a cell size variable to solve this same problem (though they are more likely to internally use a horizontal section plane to find intersecting walls and determine the exterior walls from a much smaller set of candidates).

 

So the room around the entire design is probably the best solution with the least requirements, but it will need some non-trivial modifications to be able to handle designs with stacked walls

0 Likes
Message 32 of 32

jeremy_tammik
Alumni
Alumni

Thank you very much confirming the usefulness and pointing out the weaknesses and workarounds. I shared your valuable advice and experience on the blog to ensure it is not lost:

 

https://thebuildingcoder.typepad.com/blog/2022/06/outer-walls-lookup-update-and-filtering.html#4

  

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