Пример #1
0
        /// <summary>
        /// Return a document set as an IEnumerable by building a list
        /// </summary>
        /// <param name="ds">the document set source</param>
        /// <returns>an IEnumerable for the DocumentSet</returns>
        public static IEnumerable <Document> GetEnumerable(this DocumentSet ds)
        {
            List <Document>     docSetEnum = new List <Document>();
            DocumentSetIterator iter       = ds.ForwardIterator();

            while (iter.MoveNext())
            {
                docSetEnum.Add((Document)iter.Current);
            }

            return(docSetEnum);
        }
Пример #2
0
        BatchPrinting()
        {
            try {
                /// get files to process from user
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title       = "Select all files to send to printer";
                openFileDialog.Multiselect = true;
                openFileDialog.Filter      = "RVT Files (*.rvt)|*.rvt";

                DocumentSet docSet = new DocumentSet();

                if (openFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                /// create a document set of all selected files
                foreach (string fileName in openFileDialog.FileNames)
                {
                    /// could directly deal with doc here but...
                    /// just testing out DocumentSet
                    Document doc = m_revitApp.Application.OpenDocumentFile(fileName);
                    docSet.Insert(doc);
                }


                /// process each file in the Document set
                DocumentSetIterator docSetIter = docSet.ForwardIterator();
                while (docSetIter.MoveNext())
                {
                    Document doc = docSetIter.Current as Document;

                    ViewSet views = Utils.View.GetAvailableViewsToExport(doc);

                    /// TBD: remove comments after figuring out
                    /// why doc.EndTransaction() triggers asserts,
                    /// Note that it still works , but the asserts can be a nuisance
                    /// while dealing with multiple files 01/12/07

                    ///// align text middle and center
                    //TextAlignFlags align = TextAlignFlags.TEF_ALIGN_MIDDLE ^ TextAlignFlags.TEF_ALIGN_CENTER;

                    ///// the way to add an element for a document
                    ///// in memory is within a transaction
                    //if (doc.BeginTransaction()) {

                    //    /// to identify what is printed
                    //    foreach (Autodesk.Revit.DB.View view in views) {

                    //        XYZ origin = new XYZ(view.CropBox.Max.X, view.CropBox.Min.Y, 0.0);
                    //        doc.Create.NewTextNote(view, origin, GeomUtils.kXAxis,
                    //                               view.ViewDirection, 15.0, .25,
                    //                               align, view.ViewName);

                    //    }
                    //}

                    ///// TBD: Asserts "unnamed transaction" ... dunno why
                    ////doc.EndTransaction();
                    //doc.Save();

                    ///// print now
                    doc.Print(views);
                }

                /// feedback to user
                MessageBox.Show("Done Printing!");
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Peforms a batch process on selected files
        /// </summary>
        public void BatchPrinting()
        {
            try {
                /// get files to process from user
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title = "Select all files to send to printer";
                openFileDialog.Multiselect = true;
                openFileDialog.Filter = "RVT Files (*.rvt)|*.rvt";

                DocumentSet docSet = new DocumentSet();

                if (openFileDialog.ShowDialog() != DialogResult.OK) {
                    return;
                }

                /// create a document set of all selected files
                foreach (string fileName in openFileDialog.FileNames) {
                    /// could directly deal with doc here but...
                    /// just testing out DocumentSet
                    Document doc = m_revitApp.Application.OpenDocumentFile(fileName);
                    docSet.Insert(doc);
                }

                /// process each file in the Document set
                DocumentSetIterator docSetIter = docSet.ForwardIterator();
                while (docSetIter.MoveNext()) {

                    Document doc = docSetIter.Current as Document;

                    ViewSet views = Utils.View.GetAvailableViewsToExport(doc);

                    /// TBD: remove comments after figuring out
                    /// why doc.EndTransaction() triggers asserts,
                    /// Note that it still works , but the asserts can be a nuisance
                    /// while dealing with multiple files 01/12/07

                    ///// align text middle and center
                    //TextAlignFlags align = TextAlignFlags.TEF_ALIGN_MIDDLE ^ TextAlignFlags.TEF_ALIGN_CENTER;

                    ///// the way to add an element for a document
                    ///// in memory is within a transaction
                    //if (doc.BeginTransaction()) {

                    //    /// to identify what is printed
                    //    foreach (Autodesk.Revit.DB.View view in views) {

                    //        XYZ origin = new XYZ(view.CropBox.Max.X, view.CropBox.Min.Y, 0.0);
                    //        doc.Create.NewTextNote(view, origin, GeomUtils.kXAxis,
                    //                               view.ViewDirection, 15.0, .25,
                    //                               align, view.ViewName);

                    //    }
                    //}

                    ///// TBD: Asserts "unnamed transaction" ... dunno why
                    ////doc.EndTransaction();
                    //doc.Save();

                    ///// print now
                    doc.Print(views);
                }

                /// feedback to user
                MessageBox.Show("Done Printing!");
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
            }
        }