I have quite a few walls where I’m needing to split them horizontally so that I can create a parapet wall at the top. I found a post about splitting walls vertically from 2017 and they said it wasn’t possible at that time. I thought I’d check to see if it was possible now.
How would you do this in the UI?
Likely you’ll need to set the wall’s height and make a new wall with the base at the height of the old wall extending to the upper limit, just like in the UI.
yeah walls can be created by locationline- so get the walls base and top constraints and offsets- then change the original walls and create new walls by location line- setting the old walls height to the split line and your new walls base to the split line.
Code created by Eden BIM API Solution.
# Add references to access the Revit API
from Autodesk.Revit.DB import *
# Add references to access RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Point to the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument
# Inputs from Dynamo
input_wall = IN # Wall or list of walls from Dynamo input
splitHeight = IN / 304.8 # Height to start the gap from the base
gapHeight = IN / 304.8 # Height of the gap
# Check if input_wall is a list or a single item. If single, make it a list.
walls = [UnwrapElement(input_wall)] if not isinstance(input_wall, list) else [UnwrapElement(w) for w in input_wall]
def split_wall_with_gap(w, height, gap):
# Get the original wall height
wallHeight = w.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble()
# Check if split height + gap is greater than or equal to the original wall height
if height + gap >= wallHeight:
return ("Error: Split height plus gap is greater than or equal to the original wall height for Wall ID: " + str(w.Id), None)
# Get wall's location curve, type, base offset, and structural flag
curve = w.Location.Curve
wallType = w.WallType
base_offset_param = w.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET)
base_offset = base_offset_param.AsDouble() if base_offset_param else 0.0
structural_param = w.get_Parameter(BuiltInParameter.WALL_STRUCTURAL_SIGNIFICANT)
is_structural = structural_param.AsInteger() == 1 if structural_param else False
# Create the bottom wall
bottom_wall = Wall.Create(doc, curve, wallType.Id, w.LevelId, height, base_offset, w.Flipped, is_structural)
# Adjust the original wall's base offset and height
w.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).Set(height + base_offset + gap)
return (bottom_wall, w)
except Exception as e:
return (str(e), None)
# Start a transaction
# Process each wall
results = [split_wall_with_gap(w, splitHeight, gapHeight) for w in walls]
# End the transaction
# If input was a single wall, return only the first result, else return all
OUT = results if not isinstance(input_wall, list) else results
The provided Dynamo script is tailored for Autodesk Revit, facilitating the addition of gaps in walls. By importing essential Revit API and Dynamo libraries, it can seamlessly interact with and modify wall elements. Users input either a single wall or a list, specify a height for the gap’s commencement, and define the gap’s magnitude. The script, for every specified wall, validates the input, discerns the wall’s attributes, and crafts a new wall segment that concludes at the desired split height. It then refines the original wall to commence post-gap. This entire operation is securely wrapped within a transaction to ensure the Revit model’s data integrity. In essence, the script streamlines the often repetitive task of introducing architectural gaps, enhancing efficiency in design workflows.
I can take this and and add some DataShapes UI and have it convert inches to mm and we should be in business!
It is up and running, but I did notice that it doesn’t work if there are windows in the Wall since it replaces the bottom of the wall instead of the top.
I tried tweaking it myself but couldn’t quite get it to work correctly.