Hi All,
I wonder if someone successfully used MoveSlotTo function for PanelViewSchedule?
I have tried to apply workflow described here:
https://knowledge.autodesk.com
I was able to successfully get some data from functions:
GetCellsBySlotNumber
GetSlotNumberByCell
GetCircuitByCell
Unfortunately function CanMoveSlotTo returns always false.
Here is some sample code:
public void PanelScheduleTest() { Document aDocument = this.ActiveUIDocument.Document; //Get all PanelScheduleView in model List<PanelScheduleView> aPanelScheduleViewList= new FilteredElementCollector(aDocument).OfClass(typeof(PanelScheduleView)).Cast<PanelScheduleView>().ToList(); using(Transaction aTransaction = new Transaction(aDocument, "PanelScheduleTest")) { aTransaction.Start(); //Get one specific item. For test purpose only aPanelScheduleViewList.RemoveAll(x => x.Id.IntegerValue != 14407298); PanelScheduleView aPanelScheduleView = aPanelScheduleViewList.First(); int aIndex = 0; while (aPanelScheduleView.IsRowInCircuitTable(aIndex)) { ElectricalSystem aElectricalSystem = aPanelScheduleView.GetCircuitByCell(aIndex, 0); int aSlotNumber = aPanelScheduleView.GetSlotNumberByCell(aIndex, 0); if(aElectricalSystem != null) { if(aElectricalSystem.LoadName.ToUpper().Contains("LIGHTING")) { IList<int> aColumnList = new List<int>(); IList<int> aRowList = new List<int>(); aPanelScheduleView.GetCellsBySlotNumber(aIndex, out aRowList, out aColumnList); if(aPanelScheduleView.CanMoveSlotTo(aRowList.Last(), aColumnList.First(), aRowList.Last() + 20, aColumnList.Last())) aPanelScheduleView.MoveSlotTo(aRowList.Last(), aColumnList.First(), aRowList.Last() + 20, aColumnList.Last()); } } aIndex++; } aTransaction.Commit(); } }
I also tried to test it by looping via many combinations of cells:
for(int i=0; i < 20; i++) for(int j=0; j < 20; j++) for(int k=0; k < 20; k++) for(int l=0; l < 20; l++) if(aPanelScheduleView.CanMoveSlotTo(i, j, k, l)) aPanelScheduleView.MoveSlotTo(i, j, k, l);
Unfortunately no luck also here... then I tried enclose MoveSlotTo in try {} catch{} block and loop through many combinations. No luck.
Before running the script I make sure all slots are unlocked and I can move them in panel schedule interface.
Any hints?
Thank you in advance.
Best regards,
Jakub