Delete a duct

i was trying to delete a duct using python. but i failed.

import clr
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Mechanical import *

from Autodesk.Revit.UI import *

from System.Collections.Generic import List

import Revit

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.

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

elem = UnwrapElement(IN[0])


#Assign your output to the OUT variable.
OUT = elem

The Delete() method takes an ElementId as parameter, not the actual element.

Edit: and remember to close your transaction again. See more in the documentation here on transactions:

can you advise how to resolve it?

You can retrieve an elements id property by using dot notation. You could do something like:

elem = UnwrapElement(IN[0])

elemId = elem.Id


This will only work for a single item though. If you have several ducts, you’ll need to iterate through them all. Is there a reason why you aren’t using one of the delete nodes that already exists? I think there’s one in springs, clockwork and rhythm.

first thing, we can’t depend always packages. in my opinion python code is better than dynamo nodes.

its working, thank you for your help

Fair enough if that is your or your company’s view, but personally I think you are missing out on a lot of good functionalities, which will be extremely time consuming to recreate on your own. But it is, of cause, your desicion :-).

Please mark post as solved.

i tried to find out the delete node in clockwork package, but i didn’t find that. I don’t know why. some times version issues are there.

As I wrote earlier, I couldn’t quite remember if there was a version in Clockwork, but there’s plenty to choose from :slight_smile:

And im sure there are others :slight_smile:

1 Like

Follow the guide Erik created here in order to install Orchid:

It’s supported for both 1.3 and 2.0.