Coordination model purge

Hi,

This is a quick question as I can’t find any nodes that will perform this task but is there any way that you can find all linked in coordination models so that I can purge them out to clean the model for export

@kieran.atherton ,

You mean clean up all linked files?

Hi Draxl, I have a script that purges all the linked files out the model but it doesn’t seem to be able to purge the coordination models for some reason.

Hi @kieran.atherton ,

Can you share that script?

Purge model.dyn (62.9 KB)
its a script that Gavin Crump kindly created but it doesnt seem to find and purge coordination models but im not sure theres a node that will find coordination import links

Yes that script should only purge linked models/CAD. Haven’t looked into coordination models before as I rarely use them.

Hi Gavin, I just seen this article:

is this still the case ?

surely, there must be a way of finding/striping coordination models in Dynamo

It appears there is no references to coordination models in revit api docs aside from the builtin category and a postable command to link one. Usually thats a sign its not available to interact with in the API.

I believe they have their own category: BuiltInCategory Enumeration

1 Like

Yes I spoke too soon… that means we can still get it as an element and delete it. Nice one.

The below Python script will delete all coordination models it can. It appears they are stored as an element type, a bit like a revit link type would be. The category by default can return either the types or instances, but it looks like the instances aren’t able to be deleted.

# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au

# Boilerplate text
import clr

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

clr.AddReference("RevitAPI")
import Autodesk 
from Autodesk.Revit.DB import *

# Current doc/app/ui
doc = DocumentManager.Instance.CurrentDBDocument

# Get all coord models
coordModels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Coordination_Model).WhereElementIsElementType().ToElements()

results = []

# Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for c in coordModels:
    try:
        doc.Delete(c.Id)
        results.append(True)
    except:
        results.append(False)

TransactionManager.Instance.TransactionTaskDone()

OUT = results
1 Like