How to adjust the room bounding box with respect to the ceiling

How to adjust this limit offset of a room. The limit offset should change with respect to the ceiling height. Here for a same floor different ceiling height present. Same type floor and slab were used. Can you share ideas to automate this using dynamo in revit.

The process might be a little more or less involved depending on your exact scenario but the general steps would be:

  1. Get the location of each room.
  2. Get the ceiling element directly above that point.
  3. Get the ceiling element’s offset from level.
  4. Apply that value to the Limit Offset.