Change electrical circuit number

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

Anybody? :frowning:

Bump

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"
2 Likes

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

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.

1 Like

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:

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

2 Likes

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

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

1 Like

Hello,

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

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.

Hi Guys,

Firstly thanks for sharing this.

Also I realise this post was a long time ago however I am just trying to understand what the +1 are for in this python and how you count the cells in the schedule to ensure i am moving the right row.

I am thinking i am having issues with what column \ row i am assigning.
I am not sure whether to include the 9 rows before the first circuit or not.
This is what i have.

I have 8 rows in my header
Then 1 row above the circuits eg circuit descriptions etc

I am getting this error.

image

Hello there @bwilkeA77N6.
I am sorry to say I do not recall alot about this code,
but I do recall an issue where my panel schedule did not show
load balancing, hence all circuits numbers were in the same column.
I believe the python script was only compatible with the layout I was using because of the cell references.

Your error seems like you are trying to access the MoveSlotTo property on the list level instead of the object level, so you might have to loop through what ever property/object is on line 23.

Hi Andre,

I found out where i was going wrong. I was giving the node a list not and object. added ‘Get item at index’ and it solved it.

Did you work out a solution where there was a item already at the circuits location?

Thanks Again.

That is great to hear :slight_smile:
No, sadly I never got around to work with this node after the feedback.

If the new slot already has a circuit then the existing circuit must be moved first. You could use CanMoveSlotTo() to first check to see if the slot is available. If not, use MoveSlotTo() on the existing circuit to move it to an open slot.

Hi Nick,

Thanks for getting back to me. I have tried the CanMoveSlotTo method however im not sure where to go next as im just a beginner at Python.

Hopefully you may be able to help with the IF statement if i tell you what i am after.

If CanMoveSlotTo
then PS.MoveSlotTo(nMovingRow,nMovingCol,nToRow,nToCol)
.
If not move existing circuit to last in panel then move the circuit

this is what i put together but it doesn’t work :frowning:

<if PS.CanMoveSlotTo(nMovingRow, nMovingCol, nToRow, nToCol):
PS.MoveSlotTo(nMovingRow, nMovingCol, nToRow, nToCol)
else:
last_circuit = len(PS.CircuitIds)
PS.MoveSlotTo(nMovingRow, nMovingCol, last_circuit)

TransactionManager.Instance.TransactionTaskDone()

OUT = “Done”>

Hope its not to confusing…
Thanks in advance

Brock

Make sure you share code using preformatted text (</>) so it’s legible. Can you show us your code in action and any errors you’re getting. We need the full picture.

Don’t know if you still need a solution, but have a look at the RIE package.

image

1 Like