예제 #1
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                ExternalApp.FirstTimeRun(); // analytics
                Document doc = commandData.Application.ActiveUIDocument.Document;

                IList <Document> inMemory = Utilities.RevitUtils.GetProjectsInMemory(commandData.Application.Application);

                UI.ExportSelectionForm form = new UI.ExportSelectionForm(inMemory, doc);
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return(Result.Cancelled);
                }

                string filename = form.Filename;

                //store for the future? seems like there are suddenly problems with reading this info back...
                commandData.JournalData.Add("DocumentName", form.SelectedDocument.Title);
                commandData.JournalData.Add("Filename", form.Filename);

                SnapshotMaker maker = new SnapshotMaker(form.SelectedDocument, form.Filename);
                maker.Export();

                TaskDialog td = new TaskDialog("Fingerprint");
                td.MainContent     = "The snapshot file has been created.";
                td.ExpandedContent = "File: " + filename + Environment.NewLine + "Duration: " + maker.Duration.TotalMinutes.ToString("F2") + " minutes.";
                td.Show();

                GC.Collect();
                GC.WaitForPendingFinalizers();



                return(Result.Succeeded);
            }
            catch (ApplicationException aex)
            {
                MessageBox.Show(aex.Message);
                return(Result.Cancelled);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex);
                return(Result.Failed);
            }
        }
예제 #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                UIDocument uidoc = commandData.Application.ActiveUIDocument;
                Document   doc   = uidoc.Document;

                IList <Document> inMemory = Utilities.RevitUtils.GetProjectsInMemory(commandData.Application.Application);

                IEnumerable <RevitLinkInstance> rvtLinks = new FilteredElementCollector(doc).OfClass(typeof(RevitLinkInstance)).ToElements().Cast <RevitLinkInstance>();

                IList <Document> linkDocs = rvtLinks.Select(rvt => rvt.GetLinkDocument()).ToList();


                UI.ExportSelectionForm form = new UI.ExportSelectionForm(inMemory, doc);

                if (form.ShowDialog() != DialogResult.OK)
                {
                    return(Result.Cancelled);
                }



                string filename = form.Filename;

                Document linkRvtDoc = null;

                foreach (Document linkDoc in linkDocs)
                {
                    try
                    {
                        if (linkDoc.PathName.Contains(form.SelectedDocument.PathName))
                        {
                            linkRvtDoc = linkDoc;
                        }
                    }
                    catch
                    {
                    }
                }

                SnapshotMaker maker = new SnapshotMaker(linkRvtDoc, form.Filename);
                maker.Export();

                TaskDialog td = new TaskDialog("Fingerprint");
                td.MainContent     = "The snapshot file has been created.";
                td.ExpandedContent = "File: " + filename + Environment.NewLine + "Duration: " + maker.Duration.TotalMinutes.ToString("F2") + " minutes.";
                td.Show();

                GC.Collect();
                GC.WaitForPendingFinalizers();



                return(Result.Succeeded);
            }
            catch (ApplicationException aex)
            {
                MessageBox.Show(aex.Message);
                return(Result.Cancelled);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex);
                return(Result.Failed);
            }
        }