<commit_before>using System;
using System.Collections.Generic;
using System.Text;

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;

namespace ArchivePDF.csproj
{
    class PDFArchiver
    {
        private SldWorks swApp;
        private ModelDoc2 swModel;
        private Frame swFrame;
        private DrawingDoc swDraw;
        private View swView;
        private CustomPropertyManager swCustPropMgr;
        private swDocumentTypes_e modelType = swDocumentTypes_e.swDocNONE;
        private String sourcePath = String.Empty;
        private String drawingPath = String.Empty;
        //private Boolean shouldCheck = true;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sw">Requires a <see cref="SolidWorks.Interop.sldworks.SldWorks"/> type.</param>
        public PDFArchiver(ref SldWorks sw)
        {
            swApp = sw;
            this.APathSet.KPath = @"\\AMSTORE-SVR-01\details\";
            this.APathSet.GPath = @"\\AMSTORE-SVR-22\cad\PDF ARCHIVE\";
            this.APathSet.MetalPath = @"\\AMSTORE-SVR-02\shared\shared\general\Metals\METAL MANUFACTURING\";
            swModel = (ModelDoc2)swApp.ActiveDoc;
            if (DocCheck())
            {
                swDraw = (DrawingDoc)swModel;

                if (swDraw == null)
                {
                    throw new ExportPDFException("You must have a Drawing Document open.");
                }


                String[] shtNames = (String[])swDraw.GetSheetNames();

                swFrame = (Frame)swApp.Frame();

                //This should find the first page with something on it.
                Int32 x = 0;
                while ((swView == null) && (x <= swDraw.GetSheetCount()))
                {
                    try
                    {
                        swDraw.ActivateSheet(shtNames[x]);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        throw new ExportPDFException("Went beyond the number of sheets.", e);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }

                    swView = (View)swDraw.GetFirstView();
                    swView = (View)swView.GetNextView();
                }

                if (swView == null)
                {
                    throw new ExportPDFException("I couldn't find a View.");
                }

                sourcePath = swView.GetReferencedModelName().ToUpper().Trim();
                drawingPath = swModel.GetPathName().ToUpper().Trim();

                if (sourcePath.Contains("SLDASM"))
                {
                    modelType = swDocumentTypes_e.swDocASSEMBLY;

                }
                else if (sourcePath.Contains("SLDPRT"))
                {
                    modelType = swDocumentTypes_e.swDocPART;
                }
                else
                {
                    modelType = swDocumentTypes_e.swDocNONE;
                }
            }
            else
            {
                ExportPDFException e = new ExportPDFException(String.Format("The drawing has to be saved, {0}.", System.Environment.UserName));
                throw e;
            }
        }

        public PDFArchiver(ref SldWorks sw, ArchivePDF.csproj.PathSet ps)
        {
            swApp = sw;
            this.APathSet = ps;
            swModel = (ModelDoc2)swApp.ActiveDoc;
            if (DocCheck())
            {
                swDraw = (DrawingDoc)swModel;

                if (swDraw == null)
                {
                    throw new ExportPDFException("You must have a Drawing Document open.");
                }


                String[] shtNames = (String[])swDraw.GetSheetNames();

                swFrame = (Frame)swApp.Frame();

                //This should find the first page with something on it.
                Int32 x = 0;
                while ((swView == null) && (x <= swDraw.GetSheetCount()))
                {
                    try
                    {
                        swDraw.ActivateSheet(shtNames[x]);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        throw new ExportPDFException("Went beyond the number of sheets.", e);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }

                    swView = (View)swDraw.GetFirstView();
                    swView = (View)swView.GetNextView();
                }<commit_msg>That could have been potentially embarassing.<commit_after>using System;
using System.Collections.Generic;
using System.Text;

using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;

namespace ArchivePDF.csproj
{
    class PDFArchiver
    {
        private SldWorks swApp;
        private ModelDoc2 swModel;
        private Frame swFrame;
        private DrawingDoc swDraw;
        private View swView;
        private CustomPropertyManager swCustPropMgr;
        private swDocumentTypes_e modelType = swDocumentTypes_e.swDocNONE;
        private String sourcePath = String.Empty;
        private String drawingPath = String.Empty;
        //private Boolean shouldCheck = true;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sw">Requires a <see cref="SolidWorks.Interop.sldworks.SldWorks"/> type.</param>
        public PDFArchiver(ref SldWorks sw)
        {
            swApp = sw;
            this.APathSet.KPath = @"\\AMSTORE-SVR-01\details\";
            this.APathSet.GPath = @"\\AMSTORE-SVR-22\cad\PDF ARCHIVE\";
            this.APathSet.MetalPath = @"\\AMSTORE-SVR-02\shared\shared\general\Metals\METAL MANUFACTURING\";
            swModel = (ModelDoc2)swApp.ActiveDoc;
            if (DocCheck())
            {
                swDraw = (DrawingDoc)swModel;

                if (swDraw == null)
                {
                    throw new ExportPDFException("You must have a Drawing Document open.");
                }


                String[] shtNames = (String[])swDraw.GetSheetNames();

                swFrame = (Frame)swApp.Frame();

                //This should find the first page with something on it.
                Int32 x = 0;
                while ((swView == null) && (x <= swDraw.GetSheetCount()))
                {
                    try
                    {
                        swDraw.ActivateSheet(shtNames[x]);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        throw new ExportPDFException("Went beyond the number of sheets.", e);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }

                    swView = (View)swDraw.GetFirstView();
                    swView = (View)swView.GetNextView();
                }

                if (swView == null)
                {
                    throw new ExportPDFException("I couldn't find a View.");
                }

                sourcePath = swView.GetReferencedModelName().ToUpper().Trim();
                drawingPath = swModel.GetPathName().ToUpper().Trim();

                if (sourcePath.Contains("SLDASM"))
                {
                    modelType = swDocumentTypes_e.swDocASSEMBLY;

                }
                else if (sourcePath.Contains("SLDPRT"))
                {
                    modelType = swDocumentTypes_e.swDocPART;
                }
                else
                {
                    modelType = swDocumentTypes_e.swDocNONE;
                }
            }
            else
            {
                ExportPDFException e = new ExportPDFException(String.Format("The drawing has to be saved, {0}.", System.Environment.UserName));
                throw e;
            }
        }

        public PDFArchiver(ref SldWorks sw, ArchivePDF.csproj.PathSet ps)
        {
            swApp = sw;
            this.APathSet = ps;
            swModel = (ModelDoc2)swApp.ActiveDoc;
            if (DocCheck())
            {
                swDraw = (DrawingDoc)swModel;

                if (swDraw == null)
                {
                    throw new ExportPDFException("You must have a Drawing Document open.");
                }


                String[] shtNames = (String[])swDraw.GetSheetNames();

                swFrame = (Frame)swApp.Frame();

                //This should find the first page with something on it.
                Int32 x = 0;
                while ((swView == null) && (x <= swDraw.GetSheetCount()))
                {
                    try
                    {
                        swDraw.ActivateSheet(shtNames[x++]);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        throw new ExportPDFException("Went beyond the number of sheets.", e);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }

                    swView = (View)swDraw.GetFirstView();
                    swView = (View)swView.GetNextView();
                }
{'fraction_non_alphanumeric': 0.09148434148434148, 'fraction_numerical': 0.003432003432003432, 'mean_word_length': 1.1987738740863003, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '732228', 'n_tokens_mistral': 2501, 'n_tokens_neox': 2244, 'n_words': 503}