public Cluster() : base(entTypes.Sketch) { if (I.aDoc().DocumentType != DocumentTypeEnum.kPartDocumentObject) { return; } MyXML xmlInterface = new MyXML("ClusterInterface.xml"); MyForm F = new MyForm(xmlInterface, "Кластер"); F.f.ShowDialog(); if (F.xmls.Count != 2) { return; } xml = F.xmls[1]; Dictionary <string, string> dic = new Dictionary <string, string>(); xml.set("val", F.cbs[0].Text); ClusterData.startx = 0; ClusterData.starty = 0; xml.getInt("countX", ref ClusterData.countX); xml.getInt("countY", ref ClusterData.countY); xml.getDouble("D", ref ClusterData.D, ClusterData.tol); xml.getDouble("dx", ref ClusterData.dx, ClusterData.tol); xml.getDouble("dy", ref ClusterData.dy, ClusterData.tol); xml.getInt("rotate", ref ClusterData.rotate); foreach (var item in xml.elem.Elements()) { data.Add(new ClusterData(new MyXML(item))); } // if (ClusterData.rotate == 1) // { // data.Insert(0, data[1]); // data.Remove(data[2]); // } doc = I.aDoc() as PartDocument; compDef = doc.ComponentDefinition; ps = compDef.Sketches[compDef.Sketches.Count]; if (ps.Consumed) { return; } psOut = compDef.Sketches.Add(ps.PlanarEntity); psOut.OriginPoint = ps.OriginPoint; if (ps.AxisEntity != null) { psOut.AxisEntity = ps.AxisEntity; } psOut.AxisIsX = ps.AxisIsX; psOut.NaturalAxisDirection = ps.NaturalAxisDirection; get(); }
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; } }