Hello @Thomas_Mahon, first of all, great package you have there. But i have a slight issue here, the curve.intersectall node is not working for a set of element when it is obviously intersecting. Basically it is cable tray elements. I dont mind sharing the files in private for testing. Below are some screenshots of it.
is it because it is doing clash detection based on lines??
and also do any of you know how to solve this error??

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DSCore nodes in Dynamo
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *
# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
import shutil
# Import math library
import math
from math import *
# Import BIMorphNodes
import sys
bimorph_path = r'C:\Users\JunHao\AppData\Roaming\Dynamo\Dynamo Revit\2.0\packages\bimorphNodes\bin'
sys.path.append(bimorph_path)
clr.AddReference('BimorphNodes')
import Curve as bimC
import Revit
from Revit import Element as bimR
#Import Data and Time
from datetime import datetime
now = datetime.now()
#Import System Library
import System
from System.Collections.Generic import *
from System.IO import Directory, Path
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
def UniqueList(x):
return list(dict.fromkeys(x))
def test(cc):
#remove empty list
filter(None, cc)
#Flatten single list
next(iter(cc), None)
return cc
def ToList(y):
if isinstance(y,list):
z = UnwrapElement(y)
ele = List[Element](z)
return ele
else:
z = [UnwrapElement(y)]
ele = List[Element](z)
return ele
elements = ToList(IN[0])
eles = ToList(IN[1])
#Force close any instance of transaction
TransactionManager.Instance.ForceCloseTransaction()
#Do some action in a Transaction fitting creation
TransactionManager.Instance.EnsureInTransaction(doc)
#intersect_junction = ElementIntersectsElementFilter(elements)
#eles = FilteredElementCollector( doc ).OfClass( typeof( Conduit ) ).WherePasses( intersect_junction )
try: OUT = bimR.IntersectsElement(elements,eles)
except:
import traceback
OUT = traceback.format_exc()
#Commit the entire transaction group
TransactionManager.Instance.TransactionTaskDone()
Thanks! The Element.IntersectsElement node (method) expects a list of wrapped Revit elements, so remove the UnwrapElement() from your ToList method and it should work.
I’m not sure I follow your first post - are you intersecting curves in 3D space? Are you sure they intersect? If there are any fractional inaccuracies in the location of your ducts then this may explain why their location curves fail to intersect with Curve.IntersectAll. DM me a simplified version of your file (< 20MB) which reproduces the issue and I’ll take a look.
hello there, they are definitely clashing in the 3D space
and if i were to remove unwrapelement, it will have another error not not able to cast revit.element.unknowelement to autodesk.revit.db.element.
i will dm you the download link shortly
and also i tried using Curve.IntersectAll in the python script but it gives me this error
the python code is as follows:
# Import BIMorphNodes
import sys
bimorph_path = r'C:\Users\JunHao\AppData\Roaming\Dynamo\Dynamo Revit\2.0\packages\bimorphNodes\bin'
sys.path.append(bimorph_path)
clr.AddReference('BimorphNodes')
import Curve as bimC
Ilist_curves = [tempCurve_List.ToRevitType() for tempCurve_List in tempCurves_List]
Ilist_curve = Stack[Curve](Ilist_curves)
intersect_list = bimC.IntersectAll(Ilist_curve)
whereby tempCurves_List
is a list of curve from dynamo.
To resolve the issue with unknown element: you need to qualify the Element class so the compiler resolves to the Element type in Dynamo’s Revit Elements wrapper class; currently it resolves to the Autodesk.Revit.DB.Element (i.e. RevitAPI), hence the error. So when you declare your .NET list, the syntax should be (where myElements is a list of elements selected using Dynamo nodes):
List[Revit.Elements.Element](myElements)
Next, Curve.IntersectAll takes a .NET Stack of ProtoGeometry Curves, not Revit API curves…so don’t perform any conversion (using ToRevitType()) - simply input curves from Dynamo directly into your stack and it will work.
If you add a reference to BimorphNodes in Visual Studio, you’ll be able to see all these methods in the Object Browser and check what the input types are so you know what to pass into each input.
When I have time I’ll respond to the intersection issue, but in the meantime, check if Revit hasn’t auto-joined the cable trays, if so then they technically don’t intersect so the result is correct. I have done a quick test to check if cable trays are supported by the node and they are and I get correct intersection results, so you could also test this yourself in a fresh file with some cable trays you know intersect and see if you get the same result.
1 Like
First of all, really appreciated and big thank you for your help @Thomas_Mahon. I actually had manage to solve the first two issue, thanks to your other post
, using the exact solutions you given. Im still learning Visual Studio as im also keen in developing ZeroTouchNodes, from your notes too. I will also give it a try to add reference to your nodes for a better understanding of it.
And as for the last issue, i think i know what wrongs with it already. And no revit didnt auto-joined the cable trays. The reason, i think, it cannot detect the geometry intersect is because it uses lines/curves to check for intersect, which means if the Z-axis arent align, it wont be detecting as clash. Which is exactly what happen to my case whereby the Z-axis of these two cable trays are different due to its height, they are align by bottom of tray with different height. For example, 50mm and 100mm height will bottom of tray alignment will give a difference of 25mm in Z-axis.
So i solve it by first group the cables trays of same bottom elevation together, then normalized their z-axis, then use your Curve.IntersectAll node to check for that specific set of list. Which works well.
P.S. maybe you can add the function as part of nodes to have better control, just a suggestion 
Thank you for help and time @Thomas_Mahon, really appreciated it mate