Beispiel #1
0
        ExportTo2dDwf()
        {
            /// get output dir to save DWFs to
            FolderBrowserDialog dbox = new FolderBrowserDialog();

            dbox.Description         = "Folder to save exported DWF files to";
            dbox.ShowNewFolderButton = true;

            try
            {
                if (dbox.ShowDialog() == DialogResult.OK)
                {
                    ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

                    DWFExportOptions opts = new DWFExportOptions();
                    opts.MergedViews = true;

                    /// export now
                    m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", viewsToExport, opts);

                    /// feedback to user
                    MessageBox.Show("Done exporting to 2d Dwf!!");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        Stream(ArrayList data, DWFExportOptions dwfExportOptions)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(DWFExportOptions)));

            data.Add(new Snoop.Data.Bool("Exporting areas", dwfExportOptions.ExportingAreas));
            data.Add(new Snoop.Data.Bool("Export object data", dwfExportOptions.ExportObjectData));
            data.Add(new Snoop.Data.Bool("Merged views", dwfExportOptions.MergedViews));
            data.Add(new Snoop.Data.Bool("Stop on error", dwfExportOptions.StopOnError));

            DWFExportOptions dwf2dExpOptions = dwfExportOptions as DWFExportOptions;

            if (dwf2dExpOptions != null)
            {
                Stream(data, dwf2dExpOptions);
                return;
            }

            DWFExportOptions dwf3dExpOptions = dwfExportOptions as DWFExportOptions;

            if (dwf3dExpOptions != null)
            {
                Stream(data, dwf3dExpOptions);
                return;
            }
        }
        public void ExportTo2dDwf()
        {
            /// get output dir to save DWFs to
             FolderBrowserDialog dbox = new FolderBrowserDialog();
             dbox.Description = "Folder to save exported DWF files to";
             dbox.ShowNewFolderButton = true;

             try
             {
            if (dbox.ShowDialog() == DialogResult.OK)
            {

               ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

               DWFExportOptions opts = new DWFExportOptions();
               opts.MergedViews = true;

               /// export now
               m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", viewsToExport, opts);

               /// feedback to user
               MessageBox.Show("Done exporting to 2d Dwf!!");
            }
             }
             catch (Exception e)
             {
            MessageBox.Show(e.Message);
             }
        }
Beispiel #4
0
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            Transaction transaction = new Transaction(m_activeDoc, "Export_To_DWF");

            transaction.Start();
            bool exported = false;

            base.Export();

            //parameter : ViewSet views
            ViewSet views = new ViewSet();

            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            // Export DWFx
            if (m_exportFormat == ExportFormat.DWFx)
            {
                DWFXExportOptions options = new DWFXExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas   = m_exportAreas;
                options.MergedViews      = m_exportMergeFiles;
                options.ImageFormat      = m_dwfImageFormat;
                options.ImageQuality     = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            // Export DWF
            else
            {
                DWFExportOptions options = new DWFExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas   = m_exportAreas;
                options.MergedViews      = m_exportMergeFiles;
                options.ImageFormat      = m_dwfImageFormat;
                options.ImageQuality     = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            transaction.Commit();

            return(exported);
        }
Beispiel #5
0
        ExportTo3dDwf()
        {
            // get output dir to save DWFs to
            System.Windows.Forms.FolderBrowserDialog dbox = new System.Windows.Forms.FolderBrowserDialog();
            dbox.Description         = "Folder to save exported DWF files to";
            dbox.ShowNewFolderButton = true;

            try
            {
                if (dbox.ShowDialog() == DialogResult.OK)
                {
                    ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

                    /// filter out only 3d views
                    ViewSet views3dToExport = new ViewSet();
                    foreach (Autodesk.Revit.DB.View view in viewsToExport)
                    {
                        if (view.ViewType == ViewType.ThreeD)
                        {
                            views3dToExport.Insert(view);
                        }
                    }

                    if (views3dToExport.Size == 0)
                    {
                        throw new Exception("No files exported. Make sure you have atleast one 3d view.");
                    }

                    DWFExportOptions opts = new DWFExportOptions();
                    /// export now
                    m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", views3dToExport, opts);

                    /// feedback to user
                    MessageBox.Show("Done exporting to 3d Dwf!!");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false); // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Color color = e.ObjToSnoop as Color;

            if (color != null)
            {
                Stream(snoopCollector.Data(), color);
                return;
            }

            LayoutRule layoutRule = e.ObjToSnoop as LayoutRule;

            if (layoutRule != null)
            {
                Stream(snoopCollector.Data(), layoutRule);
                return;
            }

            FormatOptions formatOptions = e.ObjToSnoop as FormatOptions;

            if (formatOptions != null)
            {
                Stream(snoopCollector.Data(), formatOptions);
                return;
            }

            CurtainGrid curtainGrid = e.ObjToSnoop as CurtainGrid;

            if (curtainGrid != null)
            {
                Stream(snoopCollector.Data(), curtainGrid);
                return;
            }

            CurtainCell curtainCell = e.ObjToSnoop as CurtainCell;

            if (curtainCell != null)
            {
                Stream(snoopCollector.Data(), curtainCell);
                return;
            }

            RebarHostData rebarHostData = e.ObjToSnoop as RebarHostData;

            if (rebarHostData != null)
            {
                Stream(snoopCollector.Data(), rebarHostData);
                return;
            }

            Leader leader = e.ObjToSnoop as Leader;

            if (leader != null)
            {
                Stream(snoopCollector.Data(), leader);
                return;
            }

            AreaVolumeSettings areaSettings = e.ObjToSnoop as AreaVolumeSettings;

            if (areaSettings != null)
            {
                Stream(snoopCollector.Data(), areaSettings);
                return;
            }

            ViewSheetSetting viewSheetSetting = e.ObjToSnoop as ViewSheetSetting;

            if (viewSheetSetting != null)
            {
                Stream(snoopCollector.Data(), viewSheetSetting);
                return;
            }

            Autodesk.Revit.UI.Events.DialogBoxData dlgBoxData = e.ObjToSnoop as Autodesk.Revit.UI.Events.DialogBoxData;
            if (dlgBoxData != null)
            {
                Stream(snoopCollector.Data(), dlgBoxData);
                return;
            }

            Construction construct = e.ObjToSnoop as Construction;

            if (construct != null)
            {
                Stream(snoopCollector.Data(), construct);
                return;
            }

            FamilyElementVisibility famElemVisib = e.ObjToSnoop as FamilyElementVisibility;

            if (famElemVisib != null)
            {
                Stream(snoopCollector.Data(), famElemVisib);
                return;
            }

            FamilyManager famManager = e.ObjToSnoop as FamilyManager;

            if (famManager != null)
            {
                Stream(snoopCollector.Data(), famManager);
                return;
            }

            FamilyParameter famParam = e.ObjToSnoop as FamilyParameter;

            if (famParam != null)
            {
                Stream(snoopCollector.Data(), famParam);
                return;
            }

            FamilyType famType = e.ObjToSnoop as FamilyType;

            if (famType != null)
            {
                Stream(snoopCollector.Data(), famType);
                return;
            }

            MEPSpaceConstruction mepSpaceConstuct = e.ObjToSnoop as MEPSpaceConstruction;

            if (mepSpaceConstuct != null)
            {
                Stream(snoopCollector.Data(), mepSpaceConstuct);
                return;
            }

            BuildingSiteExportOptions bldSiteExpOptions = e.ObjToSnoop as BuildingSiteExportOptions;

            if (bldSiteExpOptions != null)
            {
                Stream(snoopCollector.Data(), bldSiteExpOptions);
                return;
            }

            DGNExportOptions dgnExpOptions = e.ObjToSnoop as DGNExportOptions;

            if (dgnExpOptions != null)
            {
                Stream(snoopCollector.Data(), dgnExpOptions);
                return;
            }

            DWFExportOptions dwfExpOptions = e.ObjToSnoop as DWFExportOptions;

            if (dwfExpOptions != null)
            {
                Stream(snoopCollector.Data(), dwfExpOptions);
                return;
            }

            DWGExportOptions dwgExpOptions = e.ObjToSnoop as DWGExportOptions;

            if (dwgExpOptions != null)
            {
                Stream(snoopCollector.Data(), dwgExpOptions);
                return;
            }

            DWGImportOptions dwgImpOptions = e.ObjToSnoop as DWGImportOptions;

            if (dwgImpOptions != null)
            {
                Stream(snoopCollector.Data(), dwgImpOptions);
                return;
            }

            FBXExportOptions fbxExpOptions = e.ObjToSnoop as FBXExportOptions;

            if (fbxExpOptions != null)
            {
                Stream(snoopCollector.Data(), fbxExpOptions);
                return;
            }

            TrussMemberInfo trussInfo = e.ObjToSnoop as TrussMemberInfo;

            if (trussInfo != null)
            {
                Stream(snoopCollector.Data(), trussInfo);
                return;
            }

            VertexIndexPair vertIndPair = e.ObjToSnoop as VertexIndexPair;

            if (vertIndPair != null)
            {
                Stream(snoopCollector.Data(), vertIndPair);
                return;
            }

            PointElementReference ptElemRef = e.ObjToSnoop as PointElementReference;

            if (ptElemRef != null)
            {
                Stream(snoopCollector.Data(), ptElemRef);
                return;
            }

            Autodesk.Revit.DB.Architecture.BoundarySegment boundSeg = e.ObjToSnoop as Autodesk.Revit.DB.Architecture.BoundarySegment;
            if (boundSeg != null)
            {
                Stream(snoopCollector.Data(), boundSeg);
                return;
            }

            PointLocationOnCurve ptLocOnCurve = e.ObjToSnoop as PointLocationOnCurve;

            if (ptLocOnCurve != null)
            {
                Stream(snoopCollector.Data(), ptLocOnCurve);
                return;
            }

            Entity entity = e.ObjToSnoop as Entity;

            if (entity != null)
            {
                Stream(snoopCollector.Data(), entity);
                return;
            }

            Field field = e.ObjToSnoop as Field;

            if (field != null)
            {
                Stream(snoopCollector.Data(), field);
                return;
            }

            ExtensibleStorageField storeagefield = e.ObjToSnoop as ExtensibleStorageField;

            if (storeagefield != null)
            {
                Stream(snoopCollector.Data(), storeagefield);
                return;
            }

            IList <Autodesk.Revit.DB.BoundarySegment> boundSegs = e.ObjToSnoop as
                                                                  IList <Autodesk.Revit.DB.BoundarySegment>;

            if (boundSegs != null)
            {
                Stream(snoopCollector.Data(), boundSegs);
                return;
            }

            if (e.ObjToSnoop is KeyValuePair <String, String> )
            {
                KeyValuePair <String, String> stringspair = (KeyValuePair <String, String>)e.ObjToSnoop;
                Stream(snoopCollector.Data(), stringspair);
                return;
            }

            Schema schema = e.ObjToSnoop as Schema;

            if (schema != null)
            {
                Stream(snoopCollector.Data(), schema);
                return;
            }

            ElementId elemId = e.ObjToSnoop as ElementId;

            if (elemId != null)
            {
                Stream(snoopCollector.Data(), elemId);
                return;
            }

            PlanViewRange plvr = e.ObjToSnoop as PlanViewRange;

            if (plvr != null)
            {
                Stream(snoopCollector.Data(), plvr);
                return;
            }
            //TF
            RebarConstraintsManager rbcm = e.ObjToSnoop as RebarConstraintsManager;

            if (rbcm != null)
            {
                Stream(snoopCollector.Data(), rbcm);
                return;
            }

            RebarConstrainedHandle rbch = e.ObjToSnoop as RebarConstrainedHandle;

            if (rbch != null)
            {
                Stream(snoopCollector.Data(), rbch);
                return;
            }

            RebarConstraint rbc = e.ObjToSnoop as RebarConstraint;

            if (rbc != null)
            {
                Stream(snoopCollector.Data(), rbc);
                return;
            }

            //TFEND

            if (Utils.IsSupportedType(e.ObjToSnoop) && e.ObjToSnoop != null)
            {
                Utils.StreamWithReflection(snoopCollector.Data(), e.ObjToSnoop.GetType(), e.ObjToSnoop);
            }
        }
        /// <summary>
        /// Collect the parameters and export
        /// </summary>
        /// <returns></returns>
        public override bool Export()
        {
            Transaction transaction = new Transaction(m_activeDoc, "Export_To_DWF");
            transaction.Start();
            bool exported = false;
            base.Export();

            //parameter : ViewSet views
            ViewSet views = new ViewSet();
            if (m_currentViewOnly)
            {
                views.Insert(m_activeDoc.ActiveView);
            }
            else
            {
                views = m_selectViewsData.SelectedViews;
            }

            // Export DWFx
            if (m_exportFormat == ExportFormat.DWFx)
            {
                DWFXExportOptions options = new DWFXExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            // Export DWF
            else
            {
                DWFExportOptions options = new DWFExportOptions();
                options.ExportObjectData = m_exportObjectData;
                options.ExportingAreas = m_exportAreas;
                options.MergedViews = m_exportMergeFiles;
                options.ImageFormat = m_dwfImageFormat;
                options.ImageQuality = m_dwfImageQuality;
                exported = m_activeDoc.Export(m_exportFolder, m_exportFileName, views, options);
            }
            transaction.Commit();

            return exported;
        }
        public void ExportTo3dDwf()
        {
            // get output dir to save DWFs to
             System.Windows.Forms.FolderBrowserDialog dbox = new System.Windows.Forms.FolderBrowserDialog();
             dbox.Description = "Folder to save exported DWF files to";
             dbox.ShowNewFolderButton = true;

             try
             {
            if (dbox.ShowDialog() == DialogResult.OK)
            {

               ViewSet viewsToExport = Utils.View.GetAvailableViewsToExport(m_revitApp.ActiveUIDocument.Document);

               /// filter out only 3d views
               ViewSet views3dToExport = new ViewSet();
               foreach (Autodesk.Revit.DB.View view in viewsToExport)
               {
                  if (view.ViewType == ViewType.ThreeD)
                  {
                     views3dToExport.Insert(view);
                  }
               }

               if (views3dToExport.Size == 0)
                  throw new Exception("No files exported. Make sure you have atleast one 3d view.");

               DWFExportOptions opts = new DWFExportOptions();
               /// export now
               m_revitApp.ActiveUIDocument.Document.Export(dbox.SelectedPath, "", views3dToExport, opts);

               /// feedback to user
               MessageBox.Show("Done exporting to 3d Dwf!!");
            }
             }
             catch (Exception e)
             {
            MessageBox.Show(e.Message);
             }
        }
      Stream(ArrayList data, DWFExportOptions dwfExportOptions)
      {
         data.Add(new Snoop.Data.ClassSeparator(typeof(DWFExportOptions)));

         data.Add(new Snoop.Data.Bool("Exporting areas", dwfExportOptions.ExportingAreas));
         data.Add(new Snoop.Data.Bool("Export object data", dwfExportOptions.ExportObjectData));
         data.Add(new Snoop.Data.Bool("Merged views", dwfExportOptions.MergedViews));
         data.Add(new Snoop.Data.Bool("Stop on error", dwfExportOptions.StopOnError));

         DWFExportOptions dwf2dExpOptions = dwfExportOptions as DWFExportOptions;
         if (dwf2dExpOptions != null)
         {
            Stream(data, dwf2dExpOptions);
            return;
         }

         DWFExportOptions dwf3dExpOptions = dwfExportOptions as DWFExportOptions;
         if (dwf3dExpOptions != null)
         {
            Stream(data, dwf3dExpOptions);
            return;
         }
      }
        public override bool Export()
        {
            Transaction transaction = new Transaction(this.m_activeDoc, "Export_To_DWF");

            transaction.Start();
            bool result = false;

            base.Export();
            ViewSet viewSet  = new ViewSet();
            ViewSet viewSet2 = new ViewSet();

            if (this.m_currentViewOnly)
            {
                viewSet.Insert(this.m_activeDoc.ActiveView);
            }
            else
            {
                viewSet = this.m_selectViewsData.SelectedViews;
            }
            foreach (View view in viewSet)
            {
                ViewSheet viewSheet = (ViewSheet)view;
                viewSet2.Insert(viewSheet);
                Parameter parameter = viewSheet.get_Parameter("SEQUENCE#");
                if (this.m_exportFormat == ExportFormat.DWFx)
                {
                    this.m_exportFileName = string.Concat(new string[]
                    {
                        viewSheet.SheetNumber,
                        " - ",
                        viewSheet.Name,
                        " - ",
                        this.StoreNumber,
                        ".dwfx"
                    });
                    DWFXExportOptions dWFXExportOptions = new DWFXExportOptions();
                    dWFXExportOptions.ExportObjectData = this.m_exportObjectData;
                    dWFXExportOptions.ExportingAreas   = this.m_exportAreas;
                    dWFXExportOptions.MergedViews      = this.m_exportMergeFiles;
                    dWFXExportOptions.ImageFormat      = this.m_dwfImageFormat;
                    dWFXExportOptions.ImageQuality     = this.m_dwfImageQuality;
                    result = this.m_activeDoc.Export(this.m_exportFolder, this.m_exportFileName, viewSet2, dWFXExportOptions);
                }
                else
                {
                    this.m_exportFileName = string.Concat(new string[]
                    {
                        parameter.AsString(),
                        " - ",
                        viewSheet.SheetNumber,
                        " ",
                        viewSheet.Name,
                        " - ",
                        this.StoreNumber,
                        ".dwf"
                    });
                    DWFExportOptions dWFExportOptions = new DWFExportOptions();
                    dWFExportOptions.ExportObjectData = this.m_exportObjectData;
                    dWFExportOptions.ExportingAreas   = this.m_exportAreas;
                    dWFExportOptions.MergedViews      = this.m_exportMergeFiles;
                    dWFExportOptions.ImageFormat      = this.m_dwfImageFormat;
                    dWFExportOptions.ImageQuality     = this.m_dwfImageQuality;
                    result = this.m_activeDoc.Export(this.m_exportFolder, this.m_exportFileName, viewSet2, dWFExportOptions);
                }
                viewSet2.Erase(view);
            }
            transaction.Commit();
            return(result);
        }
        /// <summary>
        /// Retrieves print setting created for the specific paper size and prints all sheets in the set.
        /// </summary>
        private void button2_Click(object sender, EventArgs e)
        {
            //string sheetFileName;
            //string fullSheetFileName;
            //IList<string> fileNamesSource = new List<string>();
            //IList<string> fileNamesDefault = new List<string>();

            //Clear the fileNamesDestination
            fileNames.Clear();

            using (Transaction trans = new Transaction(doc))
            {
                //Update status window
                textBox8.Text = "Preparing print";

                trans.Start("Print!");

                List <ViewSheet> viewSheetList = new List <ViewSheet>();

                if (selectedSheetSet == "Current sheet only")
                {
                    Autodesk.Revit.DB.View view = doc.ActiveView;
                    viewSheetList.Add((ViewSheet)view);
                }
                else
                {
                    FilteredElementCollector col = new FilteredElementCollector(doc);
                    var sheetSet = col.OfClass(typeof(ViewSheetSet))
                                   .Where(x => x.Name == selectedSheetSet)
                                   .Cast <ViewSheetSet>().FirstOrDefault();
                    foreach (ViewSheet vs in sheetSet.Views)
                    {
                        viewSheetList.Add(vs);
                    }
                }

                FilteredElementCollector colPs = new FilteredElementCollector(doc);
                var printSettings = colPs.OfClass(typeof(PrintSetting)).Cast <PrintSetting>().ToHashSet();

                PrintManager pm = doc.PrintManager;
                PrintSetup   ps = pm.PrintSetup;
                pm.SelectNewPrintDriver("Bluebeam PDF");
                pm = doc.PrintManager;
                ps = pm.PrintSetup;
                var paperSizes = pm.PaperSizes;

                string title = doc.Title; //<- THIS CAN CAUSE PROBLEMS RECOGNISING THE ORIGINAL FILE NAME

                int sheetCount = 0;

                foreach (ViewSheet sheet in viewSheetList)
                {
                    #region Naming
                    //var revisionType = sheet.GetCurrentRevision();

                    FileNames fileName = new FileNames();
                    fileNames.Add(fileName);

                    Parameter sheetNumberPar = sheet.get_Parameter(BuiltInParameter.SHEET_NUMBER);
                    string    sheetNumber    = sheetNumberPar.AsString();
                    fileName.SheetNumber = sheetNumber;

                    Parameter sheetNamePar = sheet.get_Parameter(BuiltInParameter.SHEET_NAME);
                    string    sheetName    = sheetNamePar.AsString();
                    fileName.SheetName = sheetName;

                    Parameter curRevisionPar = sheet.get_Parameter(BuiltInParameter.SHEET_CURRENT_REVISION);
                    string    revision       = curRevisionPar.AsString();
                    fileName.Revision = revision;

                    Parameter curRevisionDatePar = sheet.get_Parameter(BuiltInParameter.SHEET_CURRENT_REVISION_DATE);
                    string    revisionDate       = curRevisionDatePar.AsString();
                    fileName.RevisionDate = revisionDate;

                    Parameter sheetIssueDatePar = sheet.get_Parameter(BuiltInParameter.SHEET_ISSUE_DATE);
                    string    sheetIssueDate    = sheetIssueDatePar.AsString();
                    fileName.Date = sheetIssueDate;

                    Parameter curScalePar = sheet.LookupParameter("Scale");
                    if (curScalePar != null)
                    {
                        if (curScalePar.AsString() == "As indicated")
                        {
                            Parameter curScaleManualPar = sheet.LookupParameter("Manual skala");
                            if (curScaleManualPar != null)
                            {
                                fileName.Scale = curScaleManualPar.AsString();
                            }
                        }
                        else if (curScalePar.AsString() != "As indicated")
                        {
                            fileName.Scale = curScalePar.AsString();
                        }
                    }

                    Parameter sorting1Par = sheet.LookupParameter("RDK-COM-SHT-SORTING_1");
                    string    sorting1    = sorting1Par.AsString();
                    Parameter sorting2Par = sheet.LookupParameter("RDK-COM-SHT-SORTING_2");
                    string    sorting2    = sorting2Par.AsString();
                    fileName.DrawingListCategory = sorting1 + " - " + sorting2;

                    fileName.GenerateFileName();

                    fileName.FileNameWithPath = pathToExport + fileName.FileName;                                                       //Used to copy files later

                    string printfilename = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\" + fileName.FileName; //Used to satisfy bluebeam
                    //fileNamesSource.Add(printfilename);

                    //string defaultFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                    //    + "\\" + title + " - Sheet - " + sheet.SheetNumber + " - " + sheet.Name + ".pdf";
                    //fileNamesDefault.Add(defaultFileName);

                    pm.PrintToFileName = printfilename;
                    #endregion

                    FamilyInstance titleBlock =
                        fi.GetElements <FamilyInstance, BuiltInParameter>(doc, BuiltInParameter.SHEET_NUMBER, sheet.SheetNumber).FirstOrDefault();

                    var widthPar = titleBlock.get_Parameter(BuiltInParameter.SHEET_WIDTH);
                    var width    = Convert.ToInt32(widthPar.AsDouble().FtToMm().Round(0));

                    var heightPar = titleBlock.get_Parameter(BuiltInParameter.SHEET_HEIGHT);
                    var height    = Convert.ToInt32(heightPar.AsDouble().FtToMm().Round(0));

                    var nameOfPaperSize = paperSizeDict[height][width];

                    var printSetting = (from PrintSetting pSetting in printSettings
                                        where pSetting.Name == nameOfPaperSize
                                        select pSetting).FirstOrDefault();

                    ps.CurrentPrintSetting = printSetting ?? throw new Exception($"{sheet.Name} does not have a print setting!");

                    pm.Apply();

                    //Feedback
                    sheetCount++;
                    textBox8.Text = "Sending " + sheetCount;

                    pm.SubmitPrint(sheet);

                    //Also export to DWF
                    DWFExportOptions dwfOptions    = new DWFExportOptions();
                    string           dwfExportPath = pathToExport + "\\DWF";
                    System.IO.Directory.CreateDirectory(dwfExportPath);

                    ViewSet vs = new ViewSet();
                    vs.Insert(sheet);

                    doc.Export(dwfExportPath, fileName.FileName.Remove(fileName.FileName.Length - 4), vs, dwfOptions);

                    System.Threading.Thread.Sleep(3000);
                }



                trans.Commit();
            }
            ////File handling
            //if (WaitForFile(fileNamesSource.Last(), fileNamesDefault.Last()))
            //{
            //    var result = tryOpenFiles(fileNamesSource.Last(), fileNamesDefault.Last());

            //    if (result.Item1)
            //    {
            //        foreach (var files in fileNamesSource.Zip(fileNamesDestination, Tuple.Create))
            //        {
            //            if (File.Exists(files.Item2)) File.Delete(files.Item2);
            //            File.Move(files.Item1, files.Item2);
            //        }
            //    }
            //    else if (result.Item2)
            //    {
            //        foreach (var files in fileNamesDefault.Zip(fileNamesDestination, Tuple.Create))
            //        {
            //            if (File.Exists(files.Item2)) File.Delete(files.Item2);
            //            File.Move(files.Item1, files.Item2);
            //        }
            //    }
            //    else throw new Exception("Filename handling FAILED AGAIN!!!!!!!");

            //}
            //else Shared.BuildingCoder.BuildingCoderUtilities.ErrorMsg("The copying of files failed for some reason!");
        }