Hello,
i am new to python and trying to create python script for clash detection and found some codes on forums and tried it but output is empty even it has clash. Can someone help me what i’m doing Wrong.
Version:0.9 StartHTML:00000097 EndHTML:00004880 StartFragment:00000199 EndFragment:00004842 # Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
import System
from System.Collections.Generic import *
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
# The inputs to this node will be stored as a list in the IN variables.
cate1 = UnwrapElement(IN[0])
cate2 = UnwrapElement(IN[1])
# Place your code below this line
doc = DocumentManager.Instance.CurrentDBDocument
catid1 = int(str(cate1.Id))
catid2 = int(str(cate2.Id))
coll = FilteredElementCollector(doc)
bic = System.Enum.ToObject(BuiltInCategory,catid1)
coll.OfCategory(bic).WhereElementIsNotElementType()
coll2 = FilteredElementCollector(doc)
bic2 = System.Enum.ToObject(BuiltInCategory,catid2)
coll2.OfCategory(bic2).WhereElementIsNotElementType()
for i in coll2:
clash =coll.WherePasses(ElementIntersectsElementFilter(i))
# Assign your output to the OUT variable.
OUT = coll,coll2,clash
It is empty because your ducts are not even collected in the first place. From what i am observing, you are using link file right? if it is, then the solution i tagged you will do what you require
i know where are the error. your fundamentals are wrong
You shouldnt use wherepass like this.
it should be something like this instead.
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
# Import math library
from math import *
#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
# The inputs to this node will be stored as a list in the IN variables.
cate1 = UnwrapElement(IN[0])
cate2 = UnwrapElement(IN[1])
# Place your code below this line
doc = DocumentManager.Instance.CurrentDBDocument
catid1 = int(str(cate1.Id))
bic = System.Enum.ToObject(BuiltInCategory,catid1)
catid2 = int(str(cate2.Id))
bic2 = System.Enum.ToObject(BuiltInCategory,catid2)
catEles1= FilteredElementCollector(doc).OfCategory(bic).WhereElementIsNotElementType().ToElements()
catEles2 = FilteredElementCollector(doc).OfCategory(bic2).WhereElementIsNotElementType().ToElements()
eleId1 = [ele.Id for ele in catEles1]
ids = List[ElementId](eleId1)
clash = [FilteredElementCollector(doc,ids).WherePasses(ElementIntersectsElementFilter(catEle)).ToElements() for catEle in catEles2]
# Assign your output to the OUT variable.
OUT = catEles1 ,catEles2 ,clash