# Joining multiple walls - join geometry

**URL:** <https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [November 29, 2018, 10:19am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070 "2018-11-29T10:19:08Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 10:19am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/1 "2018-11-29T10:19:08Z")

</div>

Hi Guys,

I was looking for a solution on joining multiple walls  
for example

- block wall
- plaster wall either side
- paint wall either side
- skirting wall either side

total of 7 layers of walls , its getting very time consuming for joining each wall to each other .

Any idea on how do i go ahead with a solution through dynamo.

My first approach was with selecting all walls  
then get wall curves  
get all lines parallel to each other  
group lines by distance  
then join.

logic seems easy but couldn’t get results

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [November 29, 2018, 10:35am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/2 "2018-11-29T10:35:04Z")

</div>

Do you mean something like this?

![wall%20to%20join](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/f/4f523726c7fc29681dfbc4980cd275c67f317b61.jpeg)

Just select the walls you need to join (you can also use Category \> All Elements of Category):

![Wall%20Join](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/2/92aac41fc6dcd691d646acc822266f4effc6027d.png)

With this Python script:

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)

for x in walls:
	for y in walls:
		try:
			JoinGeometryUtils.JoinGeometry(doc,x,y)
		except:
			pass

TransactionManager.Instance.TransactionTaskDone()

OUT = walls

```

![walls%20joined](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7f0654127a175535ea20c8a8763561ebe8ff2f93.jpeg)

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 10:36am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/3 "2018-11-29T10:36:29Z")

</div>

yes something like this but ,  
but should work for multiple layers

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [November 29, 2018, 10:39am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/4 "2018-11-29T10:39:45Z")

</div>

What do you mean with multiple layers? Can you post some images to better explain? Like a before/after

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 10:53am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/5 "2018-11-29T10:53:09Z")

</div>

BEFORE

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

AFTER

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

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 11:06am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/6 "2018-11-29T11:06:06Z")

</div>

@lucamanzoni  
Thanks a lot

Your script worked for this case as well,

only problem is , it joins all the walls with all the walls, creating a lot of warnings,  
can the script be modified for only intersecting walls join

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [November 29, 2018, 11:42am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/7 "2018-11-29T11:42:16Z")

</div>

Which warnings do you get? I don’t get any warning

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 12:07pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/8 "2018-11-29T12:07:15Z")

</div>

if you check warnings from the inquiry tab in revit,  
you can see , elements join but do not intersect.

In my case each wall is joined with all other all in the project.

Warnings are huge.

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [November 29, 2018, 12:52pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/9 "2018-11-29T12:52:33Z")

</div>

Ok, you are right. I guess it will take a bit of time to find a solution, maybe someone else has an idea

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 12:54pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/10 "2018-11-29T12:54:16Z")

</div>

YUP,

i am trying to filters walls  
reducing the wall elements to minimize the warnings as of now

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 29, 2018, 1:26pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/11 "2018-11-29T13:26:13Z")

</div>

@Preetesh_Magdum1,

Please limit yourself to a single topic per issue.

> [@Select Wall surroundings elements , which are plaster walls walls](https://forum.dynamobim.com/t/select-wall-surroundings-elements-which-are-plaster-walls-walls/28905/12):
>
> It is by Chynamo.

I gave an example of how I would tackle the problem there, and will reiterate here in more detail since I just closed your other topic for you.

```
Get all walls 
Get the walls direction. 
Normalize them. 
Rotate them 180 degrees as needed so they are contained in quadrant 1 or 2 (no negative Y values).
Group each wall by these vectors. 
Get the geometry for each wall.
Get the distance from each wall geometry to each other wall geometry. 
If the distance was 0, then join the walls as shown above, otherwise do nothing. 

```

If you also need to join the perpendicular walls, skip the vector bits.

Another option would be to just let the warnings occur, then use a second graph to select all join warning combinations (archilab has nodes that can help here), and unjoin them.

Also, consider using parts in the future as that would save you a lot of headache.

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 2:21pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/12 "2018-11-29T14:21:48Z")

</div>

Please do post here if you find the solution.

Thank you

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [November 29, 2018, 2:23pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/13 "2018-11-29T14:23:04Z")

</div>

Thank you @jacob.small

I am still working on the approach,

thank you,

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [November 30, 2018, 3:42pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/14 "2018-11-30T15:42:00Z")

</div>

I improved the script, so that it works only when geometries are intersecting. In this way the result is clean and there are no warnings.

 ![GeometryJoin](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/a/7a605451b2488267a94533fffc658ab78d53a770.jpeg)

![GeometryJoin](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/f/2f1f9a6740ab994552feedd7435809f17bea421e.png)

 ![GeometryJoinEnd](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/6/66e153a890dbdc7bc6c1ca806ab04109669ee621.jpeg)

The only problem is that adiacent walls, like those in your case, are not recognized as intersecting, so they won’t be joined.

Here the script:

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)

inter = [] 

for x in walls:
	for y in walls:
		filterIntersect = ElementIntersectsElementFilter(x)
		if x is not y:
			if filterIntersect.PassesFilter(y):
				inter.append(y)
				try:
					JoinGeometryUtils.JoinGeometry(doc,x,y)
				except:
					pass
			
TransactionManager.Instance.TransactionTaskDone()

OUT = inter

```

PS. As @jacob.small suggested, why don’t you simply use parts or compound walls?

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [December 5, 2018, 7:52am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/15 "2018-12-05T07:52:49Z")

</div>

thank you @lucamanzoni

I am yet trying for a solution.  
please do share if you find a solution.

thank you,

---

<div class="post-metadata">

**Author:** ![lucamanzoni](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/lucamanzoni/32/56718_2.png) [@lucamanzoni](https://forum.dynamobim.com/u/lucamanzoni)\
**Post date:** [December 5, 2018, 12:58pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/16 "2018-12-05T12:58:07Z")

</div>

I think this will work. The logic of the script is:

- If the 2 elements intersect, join them
- If not, check the distance between the location lines. If it is equal to the sum of the wall’s thicknesses, divided by two, then it means they are adjacent: join them.
- If both conditions are false, pass.

Output are the joined walls.

 ![JoinedWalls1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/d/7d27c15ad37717163cdbbd7965c82a016a16b07a.jpeg)

 ![JoinedWalls3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/a/1adef7828fc4f4741060418682c49e39093e84f1.jpeg)

 ![JoinedWalls2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a32e06fb38e09abf0704feeff6bb1d57a360e134.jpeg)

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)

joined = [] 

for x in walls:
	for y in walls:
		filterIntersect = ElementIntersectsElementFilter(x)
		if x is not y:
			if filterIntersect.PassesFilter(y):
				joined.append(y)
				try:
					JoinGeometryUtils.JoinGeometry(doc,x,y)
				except:
					pass
			else:
				point = x.Location.Curve.Origin.ToPoint()
				curve = y.Location.Curve.ToProtoType()
				distance = curve.DistanceTo(point)
				thickF = (x.Width + y.Width)/2
				thickM = UnitUtils.ConvertFromInternalUnits(thickF,DisplayUnitType.DUT_MILLIMETERS)
				if distance == thickM:
					joined.append(y)
					try:
						JoinGeometryUtils.JoinGeometry(doc,x,y)	
					except:
						pass
				
		
TransactionManager.Instance.TransactionTaskDone()

OUT = joined
```

---

<div class="post-metadata">

**Author:** ![Preetesh\_Magdum1](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@Preetesh\_Magdum1](https://forum.dynamobim.com/u/Preetesh_Magdum1)\
**Post date:** [December 5, 2018, 1:55pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/17 "2018-12-05T13:55:36Z")

</div>

Thanks a lot buddy…

i am try it out ASAP,

thank you,

---

<div class="post-metadata">

**Author:** ![Majeed\_Zoabi](https://avatars.discourse-cdn.com/v4/letter/m/db5fbb/32.png) [@Majeed\_Zoabi](https://forum.dynamobim.com/u/Majeed_Zoabi)\
**Post date:** [December 17, 2020, 7:03pm UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/18 "2020-12-17T19:03:28Z")

</div>

Hello! Thanks for your effort. The definition seems to work only for intersecting walls while ignoring adjacent pairs. I couldn’t find the cause in the script.

---

<div class="post-metadata">

**Author:** ![arincakkin](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@arincakkin](https://forum.dynamobim.com/u/arincakkin)\
**Post date:** [July 3, 2023, 12:52am UTC](https://forum.dynamobim.com/t/joining-multiple-walls-join-geometry/29070/19 "2023-07-03T00:52:00Z")

</div>

Thanks for sharing your knowledge.This is the only one that solve my issue butim getting this warningr on python node :  
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
Traceback (most recent call last):  
File “”, line 47, in   
NameError: name ‘DisplayUnitType’ is not defined
