private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e) { if (allowToCreate) { allowToCreate = false; IEnumerable <DesignOption> designOptions = new FilteredElementCollector(uiapp.ActiveUIDocument.Document).OfClass(typeof(DesignOption)).Cast <DesignOption>(); if (designOptions.ToList <DesignOption>().Count > 0) { DesignOptionsForm form = new DesignOptionsForm(uiapp); DialogResult result = form.ShowDialog(); } else { createNewDesignOptions(); } } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { uiapp = commandData.Application; IEnumerable <DesignOption> designOptions = new FilteredElementCollector(uiapp.ActiveUIDocument.Document).OfClass(typeof(DesignOption)).Cast <DesignOption>(); if (designOptions.ToList <DesignOption>().Count > 0) { DesignOptionsForm form = new DesignOptionsForm(uiapp); DialogResult result = form.ShowDialog(); } else { uiapp.Idling += Application_Idling; createNewDesignOptions(); } return(Result.Succeeded); }