How to check whether postable command ID_INTERFERENCE_CHECK is completed or not?

Hi all,

I want to check whether the interference check dialog box is closed or not and I want the script to be executed after or once the interference check report is generated.
Below is the snip that explains the requirement

Below is the code that I am working on:

import clr

import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')

import System
from System.Collections.Generic import *

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

import time

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

RunIt = IN[0]

if RunIt ==  True:
	CmndID = RevitCommandId.LookupCommandId('ID_INTERFERENCE_CHECK')
	CmId = CmndID.Id
	uiapp.PostCommand(CmndID)
	errorReport = True
	#time.sleep(delaysec)
	
else:
	errorReport = False
	
#Assign your output to the OUT variable
OUT = errorReport

I think you will need to add an event listener to Dynamo, but that said this code is already so far along that moving to an add-in or zero touch node would be preferable in terms of stability and performance (ie: listeners need to be closed or you will crash when closing files).

1 Like