Hello everyone,
I have a number of electrical circuits in my current project (more than 80). The circuit path for all of them is set by default to “Farthest device”. I would like to change all of them with dynamo to “All devices”, but i have not seen any way of doing it.
Does anybody have an idea?
Thanks,
Daniel
Hi @s258085 ,
Is the “Path Mode:” setting a parameter? Because if it is you can use, for example, the node Element.SetParameterValue.
Regards,
Daan
Unfortunately no, “Path mode” is not a parameter.
@s258085 This script will do the trick: Electrical Circuit Path Mode.dyn (8.2 KB)
#Code courtesy of http://dynamobim.ru/forums/topic/%D1%81%D0%B8%D0%BD%D1%82%D0%B0%D0%BA%D1%81%D0%B8%D1%81-revit-api-%D1%80%D0%B5%D0%B6%D0%B8%D0%BC-%D1%82%D1%80%D0%B0%D0%B5%D0%BA%D1%82%D0%BE%D1%80%D0%B8%D0%B8-%D1%8D%D0%BB%D0%B5%D0%BA%D1%82%D1%80%D0%B8/
import clr
clr.AddReference('RevitAPI',"RevitServices")
from Autodesk.Revit.DB.Electrical import ElectricalCircuitPathMode as ecpm
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
circuits = UnwrapElement(IN[0])
circuitMode = IN[1]
out = []
for circuit in circuits:
TransactionManager.Instance.EnsureInTransaction(doc)
if circuitMode:
circuit.CircuitPathMode = ecpm.AllDevices
else:
circuit.CircuitPathMode = ecpm.FarthestDevice
TransactionManager.Instance.TransactionTaskDone()
out.append(circuit.CircuitPathMode)
OUT = out
Thanks a lot, it works great!
Hello @s258085 I am trying to use this script but I believe I am having trouble selecting the “Electrical Circuit” Element in the model in order to start the scrip with the right ID#. All I am able to do now is select the Electrical Fixture (i.e. receptacle)
In order to select the electrical cirucit I use the “Categories” node, select “Electrical circuit” and then connect it with the “All elements of category” node. From the list of electrical circuits I select the one I need to as an input for the script.
@AmolShah It works fine in Revit 2020 but ‘Change Circuit Path Mode’ doesn’t work in Revit 2022. Please suggest the solution. Thanks.
Hi, @muhammad.ghufranRA2R
can you show the error ?
Hi,
try this
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
skNumber = int(app.VersionNumber)
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Electrical import *
def get_Systems(elem):
if skNumber < 2021:
systems = [e for e in elem.MEPModel.ElectricalSystems] if elem.MEPModel.ElectricalSystems is not None else []
else:
systems = [e for e in elem.MEPModel.GetElectricalSystems()]
return systems
toList = lambda x : x if hasattr(x, '__iter__') else [x]
input_elems = toList(UnwrapElement(IN[0]))
circuitMode = IN[1]
out = []
TransactionManager.Instance.EnsureInTransaction(doc)
for elem in input_elems:
for circuit in get_Systems(elem):
if circuitMode:
circuit.CircuitPathMode = ElectricalCircuitPathMode.AllDevices
else:
circuit.CircuitPathMode = ElectricalCircuitPathMode.FarthestDevice
out.append(circuit.CircuitPathMode)
TransactionManager.Instance.TransactionTaskDone()
OUT = out
Thank you dear. It works perfect.
Guys…For me I cannot select any elements when in dynamo mode…can somebody tell me step by step procedure for dynamo for change edit circuit path from farthest devices to all devices ?
Hi,
here an example
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Electrical import *
toList = lambda x : x if hasattr(x, '__iter__') else [x]
all_systems = toList(UnwrapElement(IN[0]))
circuitMode = IN[1]
out = []
TransactionManager.Instance.EnsureInTransaction(doc)
for circuit in all_systems:
if circuitMode:
circuit.CircuitPathMode = ElectricalCircuitPathMode.AllDevices
else:
circuit.CircuitPathMode = ElectricalCircuitPathMode.FarthestDevice
out.append(circuit.CircuitPathMode)
TransactionManager.Instance.TransactionTaskDone()
OUT = out