<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Exception with JoinGeometryUtils.JoinGeometry and Walls in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9953452#M29490</link>
    <description>&lt;P&gt;What's weird is that i can join the monolayer walls to the multilayer wall..&lt;/P&gt;&lt;P&gt;In my code I create a dictionnary where keys are Wall Types Id, with :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Layercount&lt;/LI&gt;&lt;LI&gt;Width of each layer&lt;/LI&gt;&lt;LI&gt;Stack width of layers&lt;/LI&gt;&lt;LI&gt;Monolayer Walls Id&lt;/LI&gt;&lt;LI&gt;Stuctural layer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Then, for each selected wall, I use this dictionnary to create the differents monolayer walls, and then i join them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joining monolayer walls to the multilayer wall is working. Not between monolayer walls :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Dic_Wall_Types[key] = [Compo_Wall.LayerCount, Widths, Stack_Wi, Monolayer_Walls, Structure]

tg = TransactionGroup(doc ,"Main")
tg.Start()
for wall in Walls_Selection :
	Object, Curves, Storage =[], [], []
	Wall_Type = wall.GetTypeId()
	Vect_API = Orientation_API(wall)	# Normal vector of the wall
	Location = wall.Location
	list_test = []

	# Get parameters values from the wall to split (level, offset,...)
	for param in Parameters :
		p = wall.LookupParameter(param)
		val = Param_Value(p, p.StorageType)
		Object.append(val)
	
	# Get Wall Type data from the Wall_Types dictionnary
	n = Dic_Wall_Types[Wall_Type][0]
	Width = Dic_Wall_Types[Wall_Type][1]
	Stack = Dic_Wall_Types[Wall_Type][2]
	Wall_Mono = Dic_Wall_Types[Wall_Type][3]
	St = Dic_Wall_Types[Wall_Type][4]

	# Creation curves of each monolayer wall to create
	for i in range(0, n) :
		a = sum(Width)/2-(Stack[i]-Width[i]/2)
		Tr = Transform.CreateTranslation(Vect_API.Multiply(a))
		c = Location.Curve.CreateTransformed(Tr)
		Curves.append(c)
	
	# Creation of monolayer walls
	t = Transaction(doc, "Creating monolayer walls")
 	t.Start()
	for index, curve in enumerate(Curves) :
		s = False
		if index == St and Object[7] == 1 :
			s = True

		mono_wall = Wall.Create(doc, curve, Wall_Mono[index], Object[0], Object[4], Object[1], False, s)
		
		Walls.append(mono_wall)
	t.Commit()
 	
 	t = Transaction(doc, "Join walls")
 	t.Start()
	for monowall1 in Walls :
		JoinGeometryUtils.JoinGeometry(doc, monowall1, wall)
		for monowall2 in Walls :
			JoinGeometryUtils.JoinGeometry(doc, monowall1, monowall2)

	t.Commit()

tg.Commit()

TaskDialog.Show("The transaction {} has ended well : {}".format(tg.GetName(), tg.HasEnded()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I run my script, then select the monolayer walls, and run the script below, it works...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;doc = DocumentManager.Instance.CurrentDBDocument 
Walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)
for wall1 in Walls :
	for wall2 in Walls :
		JoinGeometryUtils.JoinGeometry(doc, wall1, wall2)
TransactionManager.Instance.TransactionTaskDone()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made lot of tests, but unfortunately, it's never working. I have to do it in 2 steps and I can't figure out why...&lt;/P&gt;</description>
    <pubDate>Mon, 21 Dec 2020 08:58:14 GMT</pubDate>
    <dc:creator>guillain.jolivet</dc:creator>
    <dc:date>2020-12-21T08:58:14Z</dc:date>
    <item>
      <title>Exception with JoinGeometryUtils.JoinGeometry and Walls</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9949191#M29488</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm working on a python script to split a multilayer wall in several monolayer walls (a wall by layer). After creating them, i want to join them, so the hosted elements, like windows, will cut the different monolayer walls.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For exemple, i got a 3-layers-wall, and after my script i got three 1-layer-walls, in a list called Walls. And i'm doing this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;TransactionManager.Instance.EnsureInTransaction(doc)
for wall1 in Walls :
	for wall2 in Walls :
		try :
			JoinGeometryUtils.JoinGeometry(doc, wall1, wall2)
		except :
			pass
TransactionManager.Instance.TransactionTaskDone()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code, return an Exception : The elements cannot be joined. Parameter name: secondElement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, if i run my python script, create my walls, and then select the 3 walls with the dynamo node "Select Model Elements" and run an other script, it works...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;doc = DocumentManager.Instance.CurrentDBDocument 
Walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)
for wall1 in Walls :
	for wall2 in Walls :
		try :
			JoinGeometryUtils.JoinGeometry(doc, wall1, wall2)
		except :
			pass
TransactionManager.Instance.TransactionTaskDone()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why it's not working in the first script but i does in the second one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 15:41:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9949191#M29488</guid>
      <dc:creator>guillain.jolivet</dc:creator>
      <dc:date>2020-12-18T15:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Exception with JoinGeometryUtils.JoinGeometry and Walls</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9949628#M29489</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could be the created walls first need to regenerate in order to perform the JoinGeometry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the API I use a transactiongroup, so you can create the walls in a transaction, commit it and then start a new transaction for the JoinGeometry. Afterwards all transactions can be "grouped" by assimilating the transactiongroup so it's considered a single command in Revit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="TransactionGroup Class" href="https://www.revitapidocs.com/2020/65b49d46-88ec-9b8d-cd92-e3d9b2392994.htm" target="_self"&gt;TransactionGroup Class&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also the 2 loops uses the same collection, wouldn't the JoinGeometry try to join the same walls once for each wall in the collection (maybe allowed without error?). Check if it's tying to join same elements first or create a pair collection first...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Fri, 18 Dec 2020 18:38:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9949628#M29489</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-12-18T18:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Exception with JoinGeometryUtils.JoinGeometry and Walls</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9953452#M29490</link>
      <description>&lt;P&gt;What's weird is that i can join the monolayer walls to the multilayer wall..&lt;/P&gt;&lt;P&gt;In my code I create a dictionnary where keys are Wall Types Id, with :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Layercount&lt;/LI&gt;&lt;LI&gt;Width of each layer&lt;/LI&gt;&lt;LI&gt;Stack width of layers&lt;/LI&gt;&lt;LI&gt;Monolayer Walls Id&lt;/LI&gt;&lt;LI&gt;Stuctural layer&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Then, for each selected wall, I use this dictionnary to create the differents monolayer walls, and then i join them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joining monolayer walls to the multilayer wall is working. Not between monolayer walls :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Dic_Wall_Types[key] = [Compo_Wall.LayerCount, Widths, Stack_Wi, Monolayer_Walls, Structure]

tg = TransactionGroup(doc ,"Main")
tg.Start()
for wall in Walls_Selection :
	Object, Curves, Storage =[], [], []
	Wall_Type = wall.GetTypeId()
	Vect_API = Orientation_API(wall)	# Normal vector of the wall
	Location = wall.Location
	list_test = []

	# Get parameters values from the wall to split (level, offset,...)
	for param in Parameters :
		p = wall.LookupParameter(param)
		val = Param_Value(p, p.StorageType)
		Object.append(val)
	
	# Get Wall Type data from the Wall_Types dictionnary
	n = Dic_Wall_Types[Wall_Type][0]
	Width = Dic_Wall_Types[Wall_Type][1]
	Stack = Dic_Wall_Types[Wall_Type][2]
	Wall_Mono = Dic_Wall_Types[Wall_Type][3]
	St = Dic_Wall_Types[Wall_Type][4]

	# Creation curves of each monolayer wall to create
	for i in range(0, n) :
		a = sum(Width)/2-(Stack[i]-Width[i]/2)
		Tr = Transform.CreateTranslation(Vect_API.Multiply(a))
		c = Location.Curve.CreateTransformed(Tr)
		Curves.append(c)
	
	# Creation of monolayer walls
	t = Transaction(doc, "Creating monolayer walls")
 	t.Start()
	for index, curve in enumerate(Curves) :
		s = False
		if index == St and Object[7] == 1 :
			s = True

		mono_wall = Wall.Create(doc, curve, Wall_Mono[index], Object[0], Object[4], Object[1], False, s)
		
		Walls.append(mono_wall)
	t.Commit()
 	
 	t = Transaction(doc, "Join walls")
 	t.Start()
	for monowall1 in Walls :
		JoinGeometryUtils.JoinGeometry(doc, monowall1, wall)
		for monowall2 in Walls :
			JoinGeometryUtils.JoinGeometry(doc, monowall1, monowall2)

	t.Commit()

tg.Commit()

TaskDialog.Show("The transaction {} has ended well : {}".format(tg.GetName(), tg.HasEnded()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I run my script, then select the monolayer walls, and run the script below, it works...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;doc = DocumentManager.Instance.CurrentDBDocument 
Walls = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)
for wall1 in Walls :
	for wall2 in Walls :
		JoinGeometryUtils.JoinGeometry(doc, wall1, wall2)
TransactionManager.Instance.TransactionTaskDone()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made lot of tests, but unfortunately, it's never working. I have to do it in 2 steps and I can't figure out why...&lt;/P&gt;</description>
      <pubDate>Mon, 21 Dec 2020 08:58:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/9953452#M29490</guid>
      <dc:creator>guillain.jolivet</dc:creator>
      <dc:date>2020-12-21T08:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Exception with JoinGeometryUtils.JoinGeometry and Walls</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/10539821#M29491</link>
      <description>&lt;P&gt;That was the solution to my problem too.&lt;BR /&gt;Thank you for sharing!&lt;BR /&gt;Here is a very simple exemple of the GoupTransaction :&lt;BR /&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2015/02/using-transaction-groups.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2015/02/using-transaction-groups.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;/P&gt;&lt;P&gt;François Robberts&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 09:56:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/exception-with-joingeometryutils-joingeometry-and-walls/m-p/10539821#M29491</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-12T09:56:27Z</dc:date>
    </item>
  </channel>
</rss>

