internal void RenameSchedule(bool showTitle) { ++m_counter; using (Transaction t = new Transaction(m_doc, "Rename Schedule")) { ViewSchedule tmpSchedule = m_doc.GetElement(m_createdScheduleId) as ViewSchedule; string newName = GenerateName(tmpSchedule.ViewName); try { t.Start(); tmpSchedule.ViewName = newName; // Find the shared parameter utilized for grouping // schedules in the schedule browser and set it // to a particualr value tmpSchedule.LookupParameter(RebarsUtils.PARTITION) .Set(m_filtersValues[RebarsUtils.PARTITION]); // If this is the first schedule and // Show Title is ticked, then // make the title visible if (m_counter == 1 && showTitle) { tmpSchedule.Definition.ShowTitle = true; try { if (m_scheduleType == ScheduleType.AssemblySchedule) { ChangeTitle(tmpSchedule, m_filtersValues[RebarsUtils.ASSEMBLY_MARK]); } } catch (Exception ex) { Autodesk.Revit.UI.TaskDialog.Show("Exception", $"{ex.Message}\n{ex.StackTrace}."); } } else { tmpSchedule.Definition.ShowTitle = false; } } catch (Exception) { if (t.GetStatus() == TransactionStatus.Started) { t.RollBack(); } Autodesk.Revit.UI.TaskDialog.Show("Exception", $"{newName} already exists."); using (Transaction tt = new Transaction(m_doc, "Clean up")) { tt.Start(); m_doc.Delete(ScheduleId); tt.Commit(); } m_createdScheduleId = null; throw new RenameException(); } t.Commit(); } }