Change electrical circuit number

mep

#1

Hi

I am trying to make a way to change circuitnumbers to desired number instead of the automatic setup that is in Revit by default.

I have been looking in the RevitAPI, and it seems that there is a method for this :
[http://www.revitapidocs.com/2017/225a5ab5-8d2e-5fd8-ad6f-c04eb7a4d40e.htm](http://(PanelScheduleView -> MoveSlotTo))

However the input is row and cell number, which is kind of wierd, since moving a circuit includes moving the whole row of a panel schedule. Maybe I am looking in the wrong place?

  • Does anyone know how I can change a circuit number in a panel to have another (chosen) circuit number?

I have tried making a python script for this, and this is how far I have gotten at the moment + error message.

My code:

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

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB.Electrical import *
#The inputs to this node will be stored as a list in the IN variables.

OUT = list()
cellsfrom = list()
cellsto = list()

def tolist(input):
	returnlist = list()
	if isinstance(input, list):
		for item in input:
			returnlist.append(UnwrapElement(item))
	else:
		returnlist = [UnwrapElement(input)]
	return returnlist

PS = tolist(IN[0])
movefrom = tolist(IN[1])
moveto = tolist(IN[2])

for i in range(0, len(PS)):
	cellsfrom = PS[i].GetCellsBySlotNumber(movefrom[i])
	cellsto = PS[i].GetCellsBySlotNumber(moveto[i])
	for x in cellsfrom[1]:
		PS[i].MoveSlotTo(movefrom[i], x, moveto[i], x)
		
OUT = cellsfrom, cellsto

#2

Anybody? :frowning:


#3

Bump


#4

Keep in mind you can’t move a circuit to an occupied slot.

This is the code I use.

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB 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
#The inputs to this node will be stored as a list in the IN variables.

PS = UnwrapElement(IN[0])
nMovingCol = IN[1]
nMovingRow = IN[2]+1
nToCol = IN[3]
nToRow = IN[4]+1

TransactionManager.Instance.EnsureInTransaction(doc)

PS.MoveSlotTo(nMovingRow,nMovingCol,nToRow,nToCol)

TransactionManager.Instance.TransactionTaskDone()
		
OUT = "Done"

#5

I get error on nMovingCol. What number input do you give for the columns?


#6

It’s columns in the schedule, starting at 1, but I believe you can only move the slot. That’s 1 in my schedule and looks like the same for yours.


#7

Thank you so much for helping out :slight_smile:

Do you see what might be causing the error here?
I am trying to move circuit 104 to open slot 105.
There are 9 Header rows, so i have also tried inputing 113 to 114, with the same result.

By header rows i mean these:


#8

You have your columns and rows switched. The inputs are (PanelScheduleView, nMovingCol, nMovingRow, nToCol, nToRow).


#9

Oh my god. Can we pretend that was never posted?

Thank you so much :slight_smile:
That was all that was needed!


#10

Hello,

I am getting different error. Do you have any idea why i am getting this error ?


#11

Try inputing the PanelScheduleView Element instead of the Panel Schedule Name parameter into IN[0].

The error says that the data type “String” does not have an attribute called MoveSlotTo.
This is because the parameter you input to IN[0] is text, in other words a string, but a PanelScheduleView element is expected.

Hope that helps.