public void txt() { string fn = I.aDoc().FullFileName; fn = fn.Replace(".ipt", "(Кластер).txt"); using (System.IO.StreamWriter sw = System.IO.File.CreateText(fn)) { int cx = (countX * ClusterData.countX) * data.Count / 2; int cy = (countY * ClusterData.countY) * data.Count / 2; if (data.Count == 2) { cy = countY * ClusterData.countY; } double a = 0; xml.getDouble("area", ref a, 1); sw.Write("Кластер: " + MyXML.getAtt(xml.elem, "val") + "\n"); sw.Write("Количество ударов: " + cx * cy / (ClusterData.countX * ClusterData.countY) + "\n"); sw.Write("Количество отверстий по горизонтали: " + cx + " шт.\n"); sw.Write("Количество отверстий по вертикали: " + cy + " шт.\n"); sw.Write("Общее количество отверстий: " + cx * cy + " шт.\n"); sw.Write("Площадь: " + (cx * cy * a).ToString("##.####") + "мм2."); } }
private void find(fastenerSource fast) { Occ.rev = 1; fast.create(); if (fast.filter()) { return; } if (fast.l.Length < 3) { return; } xml.setRoot(); cont.setRoot(); string nameAtt = "hole"; if (fast.tf == typeFastener.slot) { nameAtt = "slot"; } if (!xml.set(xml.getEl(new Dictionary <string, string>() { { "d1", u.convToString(fast.d.First(), 3, "##.##") }, { "d2", u.convToString(fast.d.Last(), 3, "##.##") }, { "name", nameAtt } }, false))) { return; } Occ old = default(Occ); bool first = true; bool change = false; fastEdge ed = fast.fe; if (MyXML.getAtt(xml.elem, "rev") != "") { ed = fast.le; } if (contentCenter.check(ed.e as EdgeProxy)) { return; } foreach (var item in xml.elem.Elements()) { string v = MyXML.getAtt(item, "val"); string strL = MyXML.getAtt(item, "l"); string r = MyXML.getAtt(item, "rev"); if (v == "") { continue; } if (v == "rev") { Occ.rev = -1; first = true; change = true; continue; } xml.setRoot(); var spl = v.Split(':'); xml.set("abbr", spl[0]); cont.set("name", MyXML.getAtt(xml.elem, "name")); int n = int.Parse(spl[1]) - 1; cont.set(n); string name = cont.getAtt("Id"); contentCenter cc = new contentCenter(doc as Document); Occ co = cc.place(name); string fname = xml.getAtt("folder"); addToFolder(co, fname); xml.setRoot(); cont.setRoot(); if ((spl[0] == "ГЗ" || spl[0] == "ГЗП") && !first) { //co.dist = ls + lm; if (strL == "" || !u.eq(strL, fast.l[1] * 10)) { co.remove(); continue; } if (fast.fe.Equals(fast.e.First())) { Array.Reverse(fast.l); } double d = -(fast.l[0] + fast.l[1]); bool axis = false; if (r != "") { axis = !axis; d = fast.l.Sum(); } if (nameAtt == "hole") { cc.add(ed.e, co, d, !axis); } else if (nameAtt == "slot") { fastenerSlot fs = fast as fastenerSlot; FaceProxy fac = u.get <FaceProxy>(ed.e.Faces, fi => fi.SurfaceType == SurfaceTypeEnum.kPlaneSurface); if (fac != null) { cc.add(fac, co, d, axis); } if (fs.fp != null) { cc.add(fs.fp, co); } } continue; } double dist = 0; if (change) { dist = co.dist; } if (first) { if (change) { dist = (fast.l.Sum()) * Occ.rev + co.dist; } switch (fast.tf) { case typeFastener.hole: cc.add(ed.e, co, dist); break; case typeFastener.slot: fastenerSlot fs = fast as fastenerSlot; FaceProxy fac = u.get <FaceProxy>(ed.e.Faces, fi => fi.SurfaceType == SurfaceTypeEnum.kPlaneSurface); if (fac != null) { cc.add(fac, co, dist); } if (fs.fp != null) { cc.add(fs.fp, co); } break; default: break; } first = false; Occ.rev = -Occ.rev; } else { cc.add(old, co, dist); } old = co; } }