public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            // Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document      doc   = uiApp.ActiveUIDocument.Document;
            UIDocument    uidoc = uiApp.ActiveUIDocument;

            try
            {
                IList <Reference>    refs      = null;
                LegendScheduleFilter selFilter = new LegendScheduleFilter(doc);

                Selection sel = uidoc.Selection;
                refs = sel.PickObjects(ObjectType.Element, selFilter, "Select Legends and/or Schedules only.");

                InputData            inData = new InputData(doc, refs);
                LegendDuplicatorForm form   = new LegendDuplicatorForm(inData);
                form.ShowDialog();

                return(Result.Succeeded);
            }
            // Catch any exceptions and display them
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return(Result.Cancelled);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(Result.Failed);
            }
        }
Exemplo n.º 2
0
        public Result Execute(
            ExternalCommandData commandData, 
            ref string message, 
            ElementSet elements)
        {
            // Get application and document objects
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;
            UIDocument uidoc = uiApp.ActiveUIDocument;

            try
            {
                IList<Reference> refs = null;
                LegendScheduleFilter selFilter = new LegendScheduleFilter(doc);

                Selection sel = uidoc.Selection;
                refs = sel.PickObjects(ObjectType.Element, selFilter, "Select Legends and/or Schedules only.");

                InputData inData = new InputData(doc, refs);
                LegendDuplicatorForm form = new LegendDuplicatorForm(inData);
                form.ShowDialog();

                return Result.Succeeded;
            }
            // Catch any exceptions and display them
            catch (Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return Result.Cancelled;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }