Message 1 of 4
ScheduleDefinition.AddField throws exception adding shared parameter to Key Schedule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Using the API to add a shared parameter to a regular schedule works fine.
But with the same macro, ScheduleDefinition.AddField throws an exception when run on a Key Schedule: "The field specified by schedulableField may not included in this ScheduleDefinition."
Using the Revit UI, these same shared parameters can be added to the Key Schedule
RVT with document macros is attached. Activate the "Wall Schedule" and run the macro to see it work. Activate the "Wall Style Schedule" and run the macro to get the exception.
public void test()
{
Document doc = this.ActiveUIDocument.Document;
ViewSchedule vs = doc.ActiveView as ViewSchedule;
ScheduleDefinition def = vs.Definition;
ExternalDefinition extDef = MakeSharedParameter(this.Application);
using (Transaction t = new Transaction(doc, "D"))
{
t.Start();
SharedParameterElement spe = SharedParameterElement.Create(doc, extDef);
SchedulableField schedulableField = new SchedulableField(ScheduleFieldType.Instance, spe.Id);
try
{
ScheduleField scheduleField = def.AddField(schedulableField);
}
catch (Exception ex)
{
TaskDialog.Show("e", ex.Message);
}
t.Commit();
}
}
Developer Advocacy and Support +