Dynamo Script to delete all imported Cad objects

Hi BIM morph updated their nodes in V4. Does anyone know a updated version of the following Dynamo script.

Try the Crumple package. I have both a node which returns CAD Import instance/types and also a node for deletion attempting (a bit more reliable than the ootb node, and doesn’t need the user to start/end a transaction outside the node).

You can still use Bimorph nodes, they’ve just renamed some of the nodes and changed their functionality slightly.

This thread covers the changes so you can see which nodes you need to swap in/out.

@GavinCrump
fast and effective for remove elements from project; but the bad issues that imported Cad if Exploded even if we delete all instances, the link is still appear in the V&G at the imported categories🤦🏿‍♂️.
inform me if any solution founded.
Thanks in advance,

you can try this, it will delete all imported cad in the model:

image

image

import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument

if IN[0]:

	importInstances = FilteredElementCollector(doc).OfClass(Autodesk.Revit.DB.ImportInstance).ToElementIds()
	
	TransactionManager.Instance.EnsureInTransaction(doc)
	
	for importins in importInstances:
		if doc.GetElement(importins).IsLinked:
			doc.Delete(importins)
	
	TransactionManager.Instance.TransactionTaskDone()

OUT = 1
1 Like

@newshunhk
i did it but for unkown reasons the script delete the linked CADs only; and the Exploded ones are still appear in the V&G at the imported categories; as you see↓↓↓↓

oh you can modify here to false, then all imported CAD will be deleted instead
if not doc.GetElement(importins).IsLinked:

until now i amnot learn the coding :disappointed_relieved:. all i can dynamo and insert codes in dynamo.
please edit this code if it was must.
i want delete the exploded CADs not the linked CADs
Thanks in advance,

You can just copy the code… OK here I attach the script for you… :smiling_face_with_tear:
Delete_Imported_CADs.dyn (3.9 KB)

2 Likes

it worked effective;
and Imported CADs disappeared from in the V&G at the imported categories
after Purge Unused Objects
Thanks @newshunhk ;you acted as an ANGEL.

1 Like

This is amazing, and it works in Revit 2024 too; it makes my model run snappy and crisp. Why does it increase performance of BIM Revit model so much?

Imports generally add their model size to a project in their entirety, and also often have a lot of lines to be drawn on screen. Less things to draw = happier Revit!

1 Like

Or AutoCAD. Or Rhino. Even the artists making games like Grand Theft Auto (or whatever the kids are playing these days) will spend a LOT of time making their poly counts low to reduce the number of surfaces to draw at any one time, often coming up with some VERY impressive concepts and tools in order to do so… pretty much all interactive tools have an upper limit on what they like to display at one time.

1 Like