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.
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
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"
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.
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.
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.
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.
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.
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.