Пример #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
        private void updateDocumentList(Document selectedDocument)
        {
            // fill the documents to the comboxbox _cbDocuments.
            DBDocumentItem activeItem = null;

            _cbDocuments.Items.Clear();
            DocumentSetIterator docIter = _application.Documents.ForwardIterator();

            docIter.Reset();
            while (docIter.MoveNext())
            {
                Document       dbDoc        = docIter.Current as Document;
                String         documentName = null;
                DBDocumentItem item         = null;
                if (dbDoc != null)
                {
                    if (dbDoc.IsFamilyDocument)
                    {
                        item = new DBDocumentItem(dbDoc.PathName, dbDoc);
                    }
                    else
                    {
                        String projName = dbDoc.ProjectInformation.Name;
                        if (String.IsNullOrEmpty(projName) || projName.ToLower().CompareTo("project name") == 0)
                        {
                            if (String.IsNullOrEmpty(dbDoc.PathName))
                            {
                                documentName = projName;
                            }
                            else
                            {
                                documentName = new System.IO.FileInfo(dbDoc.PathName).Name;
                            }
                        }
                        else
                        {
                            documentName = projName;
                        }

                        item = new DBDocumentItem(documentName, dbDoc);
                    }
                    if (dbDoc.Equals(selectedDocument))
                    {
                        _dbDocument = selectedDocument;
                        activeItem  = item;
                    }
                    _cbDocuments.Items.Add(item);
                }
            }
            _cbDocuments.Items.Add(new DBDocumentItem());
            _cbDocuments.SelectedItem = activeItem;
        }
Пример #3
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);
            }
        }