Beispiel #1
0
        /// <summary>
        /// Selects the correct layer.
        /// </summary>
        public void chooseLayer(string rev)
        {
            char c        = (char)rev[2];
            int  revcount = (int)c - 64;

            LayerMgr lm   = (LayerMgr)(swApp.ActiveDoc as ModelDoc2).GetLayerManager();
            string   head = getLayerNameHeader(lm);

            for (int i = 0; i < Properties.Settings.Default.LayerTails.Count; i++)
            {
                string currentTail = Properties.Settings.Default.LayerTails[i];
                try {
                    Layer l = (Layer)lm.GetLayer(string.Format("{0}{1}", head, currentTail));
                    if (l != null)
                    {
                        l.Visible = false;
                        if (Math.Floor((double)((revcount - 1) / 5)) == i)
                        {
                            l.Visible = true;
                        }
                    }
                } catch (Exception) {
                    // Sometimes the layer doesn't exist.
                }
            }
        }
Beispiel #2
0
 private string getLayerNameHeader(LayerMgr lm)
 {
     foreach (string h in Properties.Settings.Default.LayerHeads)
     {
         foreach (string t in Properties.Settings.Default.LayerTails)
         {
             Layer l = (Layer)lm.GetLayer(string.Format("{0}{1}", h, t));
             if (l != null && l.Visible)
             {
                 return(h);
             }
         }
     }
     return("AMS");
 }
Beispiel #3
0
        /// <summary>
        /// Make sure we have the right layer to show the latest LVL.
        /// </summary>
        public void chooseLayer()
        {
            LayerMgr lm       = (PropertySet.SwApp.ActiveDoc as ModelDoc2).GetLayerManager();
            string   head     = getLayerNameHeader(lm);
            int      revcount = RevSet.Count - 1;

            for (int i = 0; i < Properties.Settings.Default.LayerTails.Count; i++)
            {
                string currentTail = Properties.Settings.Default.LayerTails[i];

                Layer l = (Layer)lm.GetLayer(string.Format("{0}{1}", head, currentTail));
                if (l != null)
                {
                    l.Visible = false;
                    if (Math.Floor((double)(revcount / 5)) == i)
                    {
                        l.Visible = true;
                    }
                }
            }
        }
 /// <summary>
 /// Determine whether it's an 'AMS' drawing, or otherwise.
 /// </summary>
 /// <param name="lm">A LayerMgr object.</param>
 /// <returns>The first characters of layers we want on.</returns>
 private string getLayerNameHeader(LayerMgr lm)
 {
     foreach (string h in Properties.Settings.Default.LayerHeads) {
     foreach (string t in Properties.Settings.Default.LayerTails) {
       Layer l = (Layer)lm.GetLayer(string.Format("{0}{1}", h, t));
       if (l != null && l.Visible) {
     return h;
       }
     }
       }
       return "AMS";
 }
        public void Archive()
        {
            string jsonPath = Properties.Settings.Default.defaultJSON;

            if (System.IO.File.Exists(Properties.Settings.Default.localJSON))
            {
                jsonPath = Properties.Settings.Default.localJSON;
            }

            string json    = string.Empty;
            Frame  swFrams = (Frame)swApp.Frame();

            swFrams.SetStatusBarText("Starting PDF Archiver...");
            ModelDoc2         swModel  = (ModelDoc2)swApp.ActiveDoc;
            Int32             errors   = 0;
            Int32             warnings = 0;
            swDocumentTypes_e docType;

            docType = (swDocumentTypes_e)swModel.GetType();

            if (docType != swDocumentTypes_e.swDocDRAWING)
            {
                swApp.SendMsgToUser2(string.Format("You need to have a drawing open. This is a '{0}'.", docType.ToString()),
                                     (int)swMessageBoxIcon_e.swMbStop, (int)swMessageBoxBtn_e.swMbOk);
            }
            else
            {
                // Saving first.
                if (APathSet.SaveFirst)
                {
                    try {
                        swFrams.SetStatusBarText("Saving ... this is usually the most time consuming part ...");
                        swModel.Save3((Int32)swSaveAsOptions_e.swSaveAsOptions_Silent, ref errors, ref warnings);
                    } catch (ExportPDFException e) {
                        //PDFArchiver._sendErrMessage(e, swApp);
                        ErrMsg em = new ErrMsg(e);
                        em.ShowDialog();
                    } catch (Exception ex) {
                        //PDFArchiver._sendErrMessage(ex, swApp);
                        ErrMsg em = new ErrMsg(ex);
                        em.ShowDialog();
                    }
                }

                if (APathSet.ExportPDF)
                {
                    if (ExportPdfs())
                    {
                        if (!swModel.GetPathName().ToUpper().Contains("METAL MANUFACTURING"))
                        {
                            bool     kohls = false;
                            LayerMgr lm    = (LayerMgr)swModel.GetLayerManager();
                            Layer    l     = (Layer)lm.GetLayer("KOHLS");
                            if (l != null)
                            {
                                if (l.Visible == true)
                                {
                                    kohls = true;
                                }
                            }
                            switch (kohls)
                            {
                            case true:
                                ExportKohlsThumbnail();
                                break;

                            case false:
                                ExportThumbnail();
                                break;

                            default:
                                break;
                            }
                        }
                        swFrams.SetStatusBarText(string.Format("Done exporting '{0}' to PDF Archive.", swModel.GetPathName().ToUpper()));
                    }
                    else
                    {
                        swApp.SendMsgToUser2("Failed to save PDF.",
                                             (int)swMessageBoxIcon_e.swMbStop,
                                             (int)swMessageBoxBtn_e.swMbOk);
                    }
                }
                swFrams.SetStatusBarText(":-(");
            }

            swFrams.SetStatusBarText(":-)");

            // Solidworks won't usually exit this macro on some machines. This seems to help.
            System.GC.Collect(0, GCCollectionMode.Forced);
        }