public static LayerMgr GetInstance() { if (instance == null) { instance = new GameObject("LayerMgr").AddComponent<LayerMgr>(); } return instance; }
//シングルトン用コード void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } }
public void CanPrintChange(Transform obj, bool val) { LayerMgr.GetInstance().SetCanPrint(GetObjVal(obj), val); SetLayer(); }
/// <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); }