protected CamOutResult GerberOutLayer(string path, MbeLayer.LayerValue layer) { CamOutResult result = new CamOutResult(); result.code = CamOutResult.ResultCode.NOERROR; string outpath = Path.ChangeExtension(path, MbeLayer.GetLayerName(layer)); StreamWriter streamWriter = null; try { streamWriter = new StreamWriter(outpath); int n; n = GerberHeaderStringArray.Length; for (int i = 0; i < n; i++) { streamWriter.WriteLine(GerberHeaderStringArray[i]); } OutAdCode(streamWriter, layer); OutPlotData(streamWriter, layer); n = GerberFooterStringArray.Length; for (int i = 0; i < n; i++) { streamWriter.WriteLine(GerberFooterStringArray[i]); } } catch (Exception) { result.code = CamOutResult.ResultCode.FILEERROR; result.filename = Path.GetFileName(outpath); return(result); } finally { if (streamWriter != null) { streamWriter.Close(); } } return(result); }
protected CamOutResult ExcellonDrillDataOut(string path) { CamOutResult result = new CamOutResult(); result.code = CamOutResult.ResultCode.NOERROR; string outpath = Path.ChangeExtension(path, "DRD"); StreamWriter streamWriter = null; try { streamWriter = new StreamWriter(outpath); int n; n = ExcellonHeaderStringArray.Length; for (int i = 0; i < n; i++) { streamWriter.WriteLine(ExcellonHeaderStringArray[i]); } OutDefineDrill(streamWriter); OutDrillPos(streamWriter); n = ExcellonFooterStringArray.Length; for (int i = 0; i < n; i++) { streamWriter.WriteLine(ExcellonFooterStringArray[i]); } } catch (Exception) { result.code = CamOutResult.ResultCode.FILEERROR; result.filename = Path.GetFileName(outpath); return(result); } finally { if (streamWriter != null) { streamWriter.Close(); } } return(result); }
protected CamOutResult ExcellonDrillListOut(string path) { CamOutResult result = new CamOutResult(); result.code = CamOutResult.ResultCode.NOERROR; string outpath = Path.ChangeExtension(path, "DRI"); StreamWriter streamWriter = null; try { streamWriter = new StreamWriter(outpath); streamWriter.WriteLine("Code Size(inch) Number"); //string tCode = ""; //double dia; //string str; //string platedInfo; int dataCount = baseDataList.Count; int index = 0; CamOutBaseData camd = baseDataList[index]; while (index < dataCount) { if (camd.shape == CamOutBaseData.Shape.Drill || camd.shape == CamOutBaseData.Shape.DrillPTH) { CamOutBaseData.Shape shape = camd.shape; int width = camd.width; int drillCount = 0; while (true) { index++; drillCount++; if (index >= dataCount || baseDataList[index].shape != shape || baseDataList[index].width != width) { string tCode = camd.code; double dia = (double)camd.width / 254000; string platedInfo = (camd.shape == CamOutBaseData.Shape.Drill ? "NPTH" : "PTH "); string str = string.Format("{0} {1:0.0000} {2} {3}", tCode, dia, platedInfo, drillCount); streamWriter.WriteLine(str); camd = baseDataList[index]; break; } } } else { index++; } } //string tCode = ""; //double dia; //string str; //string platedInfo; //int n = baseDataList.Count; //for (int i = 0; i < n; i++) { // CamOutBaseData camd = baseDataList[i]; // if (camd.layer != MbeLayer.LayerValue.DRL) continue; // if (tCode != camd.code) { // tCode = camd.code; // dia = (double)camd.width / 254000; // if(camd.shape == CamOutBaseData.Shape.Drill){ // platedInfo = "NPTH"; // }else{ // platedInfo = "PTH"; // } // str = string.Format("{0} {1:0.0000} {2}", tCode, dia,platedInfo); // streamWriter.WriteLine(str); // } //} } catch (Exception) { result.code = CamOutResult.ResultCode.FILEERROR; result.filename = Path.GetFileName(outpath); return(result); } finally { if (streamWriter != null) { streamWriter.Close(); } } return(result); }
/// <summary> /// Tコード、Dコード文字列の設定 /// </summary> protected CamOutResult SetCodeString() { CamOutResult result = new CamOutResult(); result.code = CamOutResult.ResultCode.NOERROR; int n = baseDataList.Count; if (n < 1) { return(result); } baseDataList.Sort(CompareBaseDataByAperture); int tSuffix = 1; int dSuffix = 10; CamOutBaseData.Shape shape = CamOutBaseData.Shape.Err; int width = 0; int height = 0; //CamOutBaseData camd = baseDataList[0]; //string strCode; //if (shape == CamOutBaseData.Shape.Drill || shape == CamOutBaseData.Shape.DrillPTH) { // strCode = string.Format("T{0:00}", tSuffix); // tSuffix++; //} else { // strCode = string.Format("D{0}", dSuffix); // dSuffix++; //} //camd.code = strCode; string strCode = ""; for (int i = 0; i < n; i++) { CamOutBaseData camd = baseDataList[i]; if (shape != camd.shape || width != camd.width || height != camd.height) { shape = camd.shape; width = camd.width; height = camd.height; if (shape == CamOutBaseData.Shape.Drill || shape == CamOutBaseData.Shape.DrillPTH) { if (tSuffix >= 100) { result.code = CamOutResult.ResultCode.TCODEOVER; return(result); } strCode = string.Format("T{0:00}", tSuffix); tSuffix++; } else { if (dSuffix >= 1000) { result.code = CamOutResult.ResultCode.DCODEOVER; return(result); } strCode = string.Format("D{0}", dSuffix); dSuffix++; } } camd.code = strCode; } return(result); }