public static bool GetDraftingConfig(DraftingConfig cDraftingConfig, Tag SheetTagAry, string PartUnits, out Drafting sDrafting) { sDrafting = new Drafting(); try { for (int i = 0; i < cDraftingConfig.Drafting.Count; i++) { NXOpen.Drawings.DrawingSheet CurrentSheet = (NXOpen.Drawings.DrawingSheet)NXObjectManager.Get(SheetTagAry); string SheetSize = cDraftingConfig.Drafting[i].SheetSize; if (PartUnits == "mm") { if (Math.Ceiling(CurrentSheet.Height) != Convert.ToDouble(SheetSize.Split(',')[0]) || Math.Ceiling(CurrentSheet.Length) != Convert.ToDouble(SheetSize.Split(',')[1])) { continue; } } else { if (Math.Ceiling(CurrentSheet.Height * 25.4) != Convert.ToDouble(SheetSize.Split(',')[0]) || Math.Ceiling(CurrentSheet.Length * 25.4) != Convert.ToDouble(SheetSize.Split(',')[1])) { continue; } } sDrafting = cDraftingConfig.Drafting[i]; } } catch (System.Exception ex) { return(false); } return(true); }
public static bool ReadDraftingConfig(string jsonPath, out DraftingConfig cDraftingConfig) { cDraftingConfig = null; try { if (!System.IO.File.Exists(jsonPath)) { return(false); } bool status; string jsonText; status = ReadFileDataUTF8(jsonPath, out jsonText); if (!status) { return(false); } cDraftingConfig = JsonConvert.DeserializeObject <DraftingConfig>(jsonText); } catch (System.Exception ex) { return(false); } return(true); }
/// <summary> /// 取得DraftingConfig.dat資料 (路徑:IP:Globaltek\ME_Config\DraftingConfig.dat) /// </summary> /// <param name="cControlerConfig"></param> /// <returns></returns> public static bool GetDraftingConfigData(out DraftingConfig cDraftingData) { cDraftingData = new DraftingConfig(); try { string DraftingConfig_dat = "DraftingConfig.dat"; string DraftingConfig_Path = string.Format(@"{0}\{1}\{2}\{3}", CaxEnv.GetGlobaltekEnvDir(), "ME_Config", "Config", DraftingConfig_dat); if (!System.IO.File.Exists(DraftingConfig_Path)) { MessageBox.Show("路徑:" + DraftingConfig_Path + "不存在"); return(false); } ReadDraftingConfig(DraftingConfig_Path, out cDraftingData); } catch (System.Exception ex) { return(false); } return(true); }