Purge Unused using Python

Hi @ashwinash112,

The Postable command works like this :

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
import Autodesk
from Autodesk.Revit.UI import RevitCommandId
from Autodesk.Revit.UI import UIApplication
from Autodesk.Revit.UI import ExternalCommandData
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication

RunIt = IN[0] 

if RunIt ==  True:
	CmndID = RevitCommandId.LookupCommandId('ID_PURGE_UNUSED')
	CmId = CmndID.Id
	uiapp.PostCommand(CmndID)
	errorReport = 'Success'
else:
	errorReport = 'Set IN[0] to true'

#Assign your output to the OUT variable
OUT = errorReport

13 Likes