Remove element from electrical circuit

I’m trying to remove an element from electrical circuit using the RemoveFromCircuit method and I’m getting the error - “RemoveFromCircuit() takes exactly 2 arguments (1 given)”
the argument should be an elementset of the components. What is the second argument?
Is there another method to remove an element from an electrical circuit?

Hello @ronit.barakiva, could you share your files to check them?

I was looking at my files again today with fresh eyes and it’s working :slight_smile:

Enable Python support and load DesignScript library

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

#import Revit Nodes
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)

#import RevitAPI
clr.AddReference(‘RevitAPI’)
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Electrical import *

#import DocumentManager and TransactionManager
clr.AddReference(‘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
ElectricalComponents = UnwrapElement(IN[0])
ElectricalCircuits = UnwrapElement(IN[1])
ElecSet = ElementSet()

Place your code below this line

for element in ElectricalComponents:
ElecSet.Insert(element)

TransactionManager.Instance.EnsureInTransaction(doc)

for circuit in ElectricalCircuits:
circuit.RemoveFromCircuit(ElecSet)

TransactionManager.Instance.TransactionTaskDone()

Assign your output to the OUT variable.

OUT = ElectricalCircuits

1 Like