Switch.join can not update

python

#1

Hi Guys
I’m having a problem using python for switch.join
It works well if everything is done before running but every time I paint the beams and run again it can not be updated. Can someone help me re-edit python
For more help see my video
href="/uploads/dynamobim/original/3X/8/0/80c6f7a27dab400ced275bbde86a54a32779092d.dyn">J.1.3.Switch Joint all in.dyn (7.5 KB)
Project2.rvt (2.6 MB)

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitAPI”)
import Autodesk

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

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
TransactionManager.Instance.EnsureInTransaction(doc)

for A in elementA:
for B in elementB:
try:
result = Autodesk.Revit.DB.JoinGeometryUtils.SwitchJoinOrder(doc,A,B)
result.append(result)
except:
pass
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = results


#2

My idea is to add the Unjoin python fragment then Joit and finally the switchjoin
But due to the low python level I do not know how to combine them into a python file
python for Unjoint

clr.AddReference(“RevitAPI”)
import Autodesk

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

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
TransactionManager.Instance.EnsureInTransaction(doc)

for A in elementA:
for B in elementB:
try:
result = Autodesk.Revit.DB.JoinGeometryUtils.UnjoinGeometry(doc,A,B)
result.append(result)
except:
pass
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = results


#3

and then python Join

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(“RevitAPI”)
import Autodesk

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

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
TransactionManager.Instance.EnsureInTransaction(doc)

for A in elementA:
for B in elementB:
try:
result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,A,B)
result.append(result)
except:
pass
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = results


#4

@Mostafa_El_Ayoubi @kennyb6 can help me?Thanks


#5

Sorry, I do not have Revit 2018 so I cannot test with your project file. As for the python, I am not sure I understand what you want. You want to just combine the three scripts in that order, Unjoin, Join, SwitchJoinOrder? Wouldn’t it be just this:

clr.AddReference(“RevitAPI”)
import Autodesk

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

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
#Unjoin
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
	for B in elementB:
		try:
			result = Autodesk.Revit.DB.JoinGeometryUtils.UnjoinGeometry(doc,A,B)
			result.append(result)
		except:
			pass
TransactionManager.Instance.TransactionTaskDone()
#Join
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
	for B in elementB:
		try:
			result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,A,B)
			result.append(result)
		except:
			pass
TransactionManager.Instance.TransactionTaskDone()
#Switch Join
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
 for B in elementB:
  try:
   result = Autodesk.Revit.DB.JoinGeometryUtils.SwitchJoinOrder(doc,A,B)
   result.append(result)
  except:
   pass
TransactionManager.Instance.TransactionTaskDone()
OUT = results

I can’t test this at the moment but if this isn’t what you want, could you try clarifying it, maybe with a drawing or explanation of what you want as the outcome?


#6

Thanh @kennyb6 for reply:
I already try this code but error "Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
unexpected token ‘’
@kennyb6 I have trouble when use switch.Join for intersection handling column-beam-floor. It does not update when I add drawing a new element
Please see my video in page #1
I need help from you


#7

Can you take a picture of the error?


#8

That error was because you were using " in the import instead of ’

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

elementA = UnwrapElement(IN[0])
elementB = UnwrapElement(IN[1])

doc = DocumentManager.Instance.CurrentDBDocument

results = []
#Unjoin
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
	for B in elementB:
		try:
			result = Autodesk.Revit.DB.JoinGeometryUtils.UnjoinGeometry(doc,A,B)
			result.append(result)
		except:
			pass
TransactionManager.Instance.TransactionTaskDone()
#Join
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
	for B in elementB:
		try:
			result = Autodesk.Revit.DB.JoinGeometryUtils.JoinGeometry(doc,A,B)
			result.append(result)
		except:
			pass
TransactionManager.Instance.TransactionTaskDone()
#Switch Join
TransactionManager.Instance.EnsureInTransaction(doc)
for A in elementA:
 for B in elementB:
  try:
   result = Autodesk.Revit.DB.JoinGeometryUtils.SwitchJoinOrder(doc,A,B)
   result.append(result)
  except:
   pass
TransactionManager.Instance.TransactionTaskDone()
OUT = results

#9

@kennyb6 You are amazing, I tried it and it successfully updated.
I spent a lot of time researching it and now you have solved it
Thanh you so much!!!


#10

No problem, glad I could help.