public static bool Export(PicFactory factory, Dictionary <PicGraphics.LT, CutTool> dicTool , double[] dimensions , string materialName, double thickness , string filePath) { List <PicTypedDrawable> lEntities = new List <PicTypedDrawable>(); ProcessEntities(factory, dicTool, ref lEntities); StringBuilder sb = new StringBuilder(); // start file with keyword ";OptiSCOUT" sb.AppendLine(";OptiSCOUT"); // total number of copies sb.AppendLine("SR1,1;"); // number of copies in X sb.AppendLine("SR2,1;"); // number of copies in Y sb.AppendLine("SR3;1;"); // type of regmark (0=Circle) sb.AppendLine("SR4,0;"); // material width in Y [mm] sb.AppendLine(string.Format("SR5,{0};", dimensions[1])); // material length in X [mm] sb.AppendLine(string.Format("SR6,{0};", dimensions[0])); // material thickness [mm] sb.AppendLine(string.Format("SR7,{0};", thickness)); // used material sb.AppendLine(string.Format("TM{0};", materialName)); bool PenDown = false, toolChanged = false; Vector2D currentPt = Vector2D.Zero; PicGraphics.LT lt = PicGraphics.LT.LT_DEFAULT; // tool Up ->lift the tool sb.AppendLine("PU;"); foreach (PicTypedDrawable entity in lEntities) { if (lt != entity.LineType) { // change current line type lt = entity.LineType; // get corresponding CutTool CutTool ct = dicTool[lt]; // SP -> change layer sb.AppendLine("PU;"); sb.AppendLine(string.Format("SP{0};LN{1};LC{2},{3},{4};TN{5}" , ct._number, ct._type, ct._color[0], ct._color[1], ct._color[2], ct._name)); toolChanged = true; } Vector2D pt0 = Vector2D.Zero, pt1 = Vector2D.Zero; if (entity is PicSegment) { PenDown = EntityPoints(entity, currentPt, ref pt0, ref pt1); // if connected, then PenDown if (!PenDown || toolChanged) { sb.AppendLine(string.Format("PU;PA{0:0},{1:0};", 100 * pt0.X, 100 * pt0.Y)); sb.AppendLine("PD;"); toolChanged = false; } sb.AppendLine(string.Format("PA{0:0},{1:0};", 100 * pt1.X, 100 * pt1.Y)); } if (entity is PicArc) { PenDown = EntityPoints(entity, currentPt, ref pt0, ref pt1); if (!PenDown || toolChanged) { sb.AppendLine(string.Format("PU;PA{0:0},{1:0};", 100 * pt0.X, 100 * pt0.Y)); sb.AppendLine("PD;"); toolChanged = false; } PicArc arc = entity as PicArc; Vector2D arcCenter = arc.Center; sb.AppendLine(string.Format("AA{0:0},{1:0},{2}" , 100 * arcCenter.X , 100 * arcCenter.Y , arc.Angle(pt0, pt1).ToString("F2", System.Globalization.CultureInfo.InvariantCulture))); } currentPt = pt1; } // write byte array to stream using (StreamWriter file = new StreamWriter(filePath, false)) file.WriteLine(sb); return(true); }