- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
One of the tools I designed is aimed at the mass creation of schedules based on selected assemblies.
The tool generally works fine, taking a template as an input value and associating it with the created schedules. This template has specific formatting for the schedule title.
However, an issue has been observed when using the tool: even though it correctly creates the schedules and associates the View Template, if the project is saved and closed without opening a schedule created by the tool, upon reopening the project, the title in this schedule displays incorrect formatting. The only way to fix this is to change the title formatting in the template to something else and then revert it to the original formatting.
The ViewSchedule.RefreshData method during the creation of schedules fixes this issue, but it significantly increases the creation time, taking up to 8 times longer than usual. Are there other ways to work around this error? Is this a known issue in the community?
private ViewSchedule Create(string assemblyName, AssemblySchedule assemblySchedule)
{
try
{
using Transaction trans = new Transaction(doc);
trans.Start("Create schedule");
ViewSchedule schedule = GetViewSchedule(assemblySchedule.SelectedScheduleType, assemblySchedule.SelectedCategory);
if (schedule == null) { return null; }
schedule.Name = GetScheduleName(assemblyName, assemblySchedule);
var template = assemblySchedule.SelectedScheduleTemplate.View;
if (template != null) { schedule.ViewTemplateId = template.Id; }
schedule.get_Parameter(BuiltInParameter.VIEW_PHASE).Set(assemblySchedule.SelectedPhase.Id);
AddFields(schedule, assemblySchedule, assemblySchedule.SelectedCategory);
//schedule.RefreshData(); //This solves the bug, but make the code significantly slower
doc.Regenerate();
SetFilter(schedule, assemblyName, assemblySchedule.SelectedCategory);
trans.Commit();
return schedule;
}
catch
{
return null;
}
}
Any insight will be much appreciated. Thanks a lot!!
Solved! Go to Solution.