# Split walls by level

**URL:** <https://forum.dynamobim.com/t/split-walls-by-level/68596>\
**Category:** Uncategorized\
**Created:** [September 27, 2021, 11:22am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596 "2021-09-27T11:22:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 11:22am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/1 "2021-09-27T11:22:24Z")

</div>

Hello again everybody !  
So i’m trying to Split the walls in my project by levels ! This is what i’ve done so far !

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/d/2d07bf30e5cbfa899ecddcfe63e63b0ab491622b.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/f/9f2aee08137dd2bf3956d343835e7d3da8a8d71d.png)

I’ve gotten the intersections between the planes created by my levels and the walls as surfaces . I’ve gotten the points to split at ! but whet i run the genius loci split by points node my wals dont split ! Am i doing something wrong ?

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [September 27, 2021, 11:36am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/2 "2021-09-27T11:36:02Z")

</div>

Hi Deejaypein,

What’s happend when you set your lacing on longest?  
I’m not sure but I think the split node need a transaction start before split the walls. (by DynaTools is it necessary)

Kg,

Jan Willem

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 27, 2021, 11:37am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/3 "2021-09-27T11:37:54Z")

</div>

> [@How to split walls per selected Level?](https://forum.dynamobim.com/t/how-to-split-walls-per-selected-level/12882/7):
>
> Here is a Dynamo script that will split the walls by level. You select the wall(s) however, and it will split it by the levels. [Split Walls By Level.dyn](https://forum.dynamobim.com/uploads/short-url/zCQtqs42UI7qktzxnYAdQOW4ckp.dyn) (7.8 KB)

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 11:43am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/4 "2021-09-27T11:43:11Z")

</div>

Thanks for your suggestion ! i’ve found this script before but i couldn’t get it to work as i get the following error on every run !

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/1/b10c370bffc012b68ab9de7123e6b8858051529c.png)

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 11:44am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/5 "2021-09-27T11:44:05Z")

</div>

When i change to longest lacing i keep getting null values on the node

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 27, 2021, 11:57am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/6 "2021-09-27T11:57:56Z")

</div>

May need to be some tweaks since that graph is 4 years old. I’ll see if I can take a look today.

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 12:00pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/7 "2021-09-27T12:00:44Z")

</div>

It would be a great help ! Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [September 27, 2021, 12:12pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/8 "2021-09-27T12:12:37Z")

</div>

Hi,

The description of the inputs is important for this node. :

 ![description](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/1/8190bce861ae1cba1cc1c114a4e90148070dd127.png)

With this custom node, you must use as many points as elements :

 ![Split walls](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8d3b34cefd9af4a1d056e0a121b59417f6256852.png)

[Split walls.dyn](https://forum.dynamobim.com/uploads/short-url/iFsN4wQCwUUrpqDSMG6VVLPHoBU.dyn) (14.6 KB)

EDIT : After checking the subject, this is not the appropriate node to split walls vertically.  
You will have better luck using the script from post 2.

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [September 27, 2021, 12:39pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/9 "2021-09-27T12:39:36Z")

</div>

heheh i find out too…always read the topic first… 😉 😉

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 27, 2021, 1:57pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/10 "2021-09-27T13:57:30Z")

</div>

Ok, so it appears in order for this graph to work, you need to make sure the Top Constraint is set to a level. If it is Unconnected, that is what makes it fail from my testing.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aa37ffbfcae185761f6fe4a4adf7ef0ca0d53e79.png)

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 2:55pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/11 "2021-09-27T14:55:24Z")

</div>

Thank you @Alban_de_Chasteigner

For the genius loci node the condition of having equal points and walls cant be satisfied in my project for the simple reason that i have walls that are created across 3 or 4 leves so 1 wall could generate 4 points . But this same node worked for me when splitting pipes by level and i had more points than pipes so i don’t understand the logic behind it

Thank you @SeanP

The top constraint is already set for all the walls in the project ! the script worked for some regular walls But it didint for some like this one

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/d/4d8bc0df6f9624771925b444daabeb575c239c3c.png)

With the Error being the following

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/c/4c1347a14393f05b72786866bc927beb710d1a66.png)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 27, 2021, 3:37pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/12 "2021-09-27T15:37:01Z")

</div>

It looks like the Top Constraint is the issue. Also, with that wall having a modified profile it may also break it.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/d/ad2c3c7536d5aa2d3b7d1952da2603656c20de17.png)

I did modify the Python to check for a null result on the Top Offset of UnConnected walls to skip them so there wouldn’t be an error/ warning.

```auto
import clr
 
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
 
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
 
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
 
import System
from System.Collections.Generic import *
 
############## Definitions Start ##############
# Convert to List if singleton...
def tolist(obj1):
    if hasattr(obj1," __iter__"): return obj1
    else: return [obj1]
     
# Returns the index of the found level given a Level and a list of Levels...
def FindLevelIndex(levels, lev):
    ind = None
    i = 0
    for l in levels:
        if l.Id.ToString() == lev.Id.ToString():
            ind = i
        i = i+1
    return ind
 
# Copy the original wall and set it's levels using the Built-In Parameters for the Base and Top Constraints...
def CopyWallByLevel(wall, b, t):
    wallOut = None
    try:
        # Copy the Original Wall with a transformation vector of 0,0,0...
        w = ElementTransformUtils.CopyElement(doc,wall.Id,XYZ(0,0,0))
        # Since the CopyElements method returns the ElementId of the new wall we need to get this Element from the Document...
        w = doc.GetElement(w[0])
        # Update the Base and Top constraints Parameters using the Built-In Parameters.
        # Note: I have explicitly chosen the Overload as I was getting flaky behaviour where the wrong overload was being used...
        p = w.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT)
        p.Set.Overloads.Functions[2](b.Id)
        p = w.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE)
        p.Set.Overloads.Functions[2](t.Id)
        wallOut = w.ToDSType(True)
    # Write out any exceptions...
    except Exception, e:
        wallOut = e.message
    # Return new wall..
    return wallOut    
############## Definitions End ##############
 
# IN-Variables...
run = tolist(IN[0])[0]
walls = tolist(UnwrapElement(IN[1]))
 
# OUT-Variables...
outList = []
 
# Main Script...
# Test if user has selected Run as True...
if run:
    # Get All Levels in the Document and cast to .net List...
    levels = list([l for l in FilteredElementCollector(doc).OfClass(Level).ToElements()])
    # Sort Levels by Elevation using a lamda expression...
    levels.sort(key=lambda x: x.Elevation, reverse=False)
     
    # Start a new Transaction ready for modifying the Document...
    TransactionManager.Instance.EnsureInTransaction(doc)
    for w in walls:
        arr = []
        # Check if the Element is a Wall...
        if w.GetType() == Wall:
            # Get Base and Top Constraints as Levels...
            p = w.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT)
            base = doc.GetElement(p.AsElementId())
            p = w.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE)
            top = doc.GetElement(p.AsElementId())
            #This test will make sure the wall is cosmtrained to a level
            if not top == None:
	            # Test whether walls Base and Top levels are NOT the same, if they are we will skip this wall, if they are not then we will get the Index of the Level in the sorted list of Levels we collected earlier for both the Base and Top of the wall...
	            if not base.Id.IntegerValue == top.Id.IntegerValue:
	                # Note: we are setting the bounds of the Loop below with the Indices of the found Levels so we will only loop through the Levels in between the Base and Top Levels...            
	                i = FindLevelIndex(levels,base)
	                j = FindLevelIndex(levels,top)
	                
	                # Loop through the Levels between the Base and Top Levels copying the original wall for each iteration and stepping up one Level...
	                while i < j:
	                    wCopy = CopyWallByLevel(w,levels[i], levels[i+1])
	                    arr.append(wCopy)    
	                    i = i+1
	                outList.append(arr)
	                # Delete original Wall as this has now been split by Level...
	                doc.Delete(w.Id)
    # End the Transaction...
    TransactionManager.Instance.TransactionTaskDone()
    # Return the new Walls...
    OUT = outList
# Return if user has not set input Run to True...
else:
    OUT = "Please Set Run to True"

```

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 4:09pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/13 "2021-09-27T16:09:56Z")

</div>

Well that one wall slipped my check 😊 Thanks for your help ! I’ll Check for the other walls ! I have another issue when the script duplicates the original wall instead of splitting it ! Like shown below .

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/2/223d435ab0f21e804c983b09de685ed62ccdfe21.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/8/b81103ebfffa4715e9832a12a419314626518dc1.png)

(I’ve checked the top constraint)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 27, 2021, 4:24pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/14 "2021-09-27T16:24:37Z")

</div>

I believe that is because that wall has a modified profile. If you do that the top constraint or constraints in general are not really followed. If you reset the profile there I would imagine you would see them all fall where you would expect them to be. In short, not really an issue with the graph per say, but more how Revit handles modified walls.

FYI - This graph is not SPLITTING the wall, it is actually duplicating the wall and then adjusting the Top and Base constraints and then deleting the original wall. Splitting Walls is not accessible via the Revit API and therefore we need this workaround to do what you are after.

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [September 27, 2021, 4:41pm UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/15 "2021-09-27T16:41:31Z")

</div>

Thank you for yout time @SeanP  
I guess i’ll split the modified walls manually for the time being untill autodesk implements splitting in the revit API !

---

<div class="post-metadata">

**Author:** ![Yong-sung.choi](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yong-sung.choi/32/61856_2.png) [@Yong-sung.choi](https://forum.dynamobim.com/u/Yong-sung.choi)\
**Post date:** [April 8, 2023, 2:32am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/16 "2023-04-08T02:32:39Z")

</div>

[![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/0/d0cc651f2e868124ffc3775d0b34706fc0d62cad.jpeg "Split wall by Level") ](https://www.youtube.com/watch?v=CHMBdgu2j5Q)

 ![02.Split Wall by Level(20230329)](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f68dbd5023f6e4f0ae577ea12efeaadfc711c9b9.png)  
[02.Split Wall by Level(20230329).dyn](https://forum.dynamobim.com/uploads/short-url/jihxUiHphdSMr3ECv3yCGNDLyF.dyn) (134.9 KB)

---

<div class="post-metadata">

**Author:** ![muhamad.mazzaz](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@muhamad.mazzaz](https://forum.dynamobim.com/u/muhamad.mazzaz)\
**Post date:** [February 2, 2024, 8:16am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/17 "2024-02-02T08:16:06Z")

</div>

Hi Yong, could you please tell me what is the custom node package you are using here

 ![Screenshot 2024-02-02 121533](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/f/cfdfbe8bd46a0c75462f4d20193f503d7d7e48a5.png)

---

<div class="post-metadata">

**Author:** ![pyXam](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/pyxam/32/163009_2.png) [@pyXam](https://forum.dynamobim.com/u/pyXam)\
**Post date:** [February 2, 2024, 8:29am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/18 "2024-02-02T08:29:54Z")

</div>

Looks like GeniusLoci

---

<div class="post-metadata">

**Author:** ![sovitek](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/sovitek/32/116237_2.png) [@sovitek](https://forum.dynamobim.com/u/sovitek)\
**Post date:** [February 2, 2024, 8:33am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/19 "2024-02-02T08:33:28Z")

</div>

or clockwork

 ![Skærmbillede 2024-02-02 093250](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/8/a87a129f9a89bce363e6a159819fadd1ac4c5b71.png)

---

<div class="post-metadata">

**Author:** ![deejaypein](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/deejaypein/32/115940_2.png) [@deejaypein](https://forum.dynamobim.com/u/deejaypein)\
**Post date:** [February 2, 2024, 8:59am UTC](https://forum.dynamobim.com/t/split-walls-by-level/68596/20 "2024-02-02T08:59:03Z")

</div>

You can get both packages. Very useful Genius Loci and Clockwork the node exists in both packages

[Next page](https://forum.dynamobim.com/t/split-walls-by-level/68596.md?page=2)
