Пример #1
0
        public Fastener(Document doc)
        {
            this.doc = doc as AssemblyDocument;
            if (this.doc == null)
            {
                return;
            }
            acd = I.getACD(doc);
            if (Macros.StandardAddInServer.xml == null)
            {
                xml = new MyXML("Fast.xml");
            }
            else
            {
                xml = Macros.StandardAddInServer.xml;
            }
            cont = new MyXML("ContentCenter.xml");
            find(acd.Occurrences);
            //faces = faces.Distinct();
            int count = faces.Count;

            //addSlot();
            foreach (var item in slots)
            {
                findSlots(item);
            }
            for (int i = 0; i < count; i++)
            {
                i++;
                List <EdgeProxy> lst = findEdges();
                if (lst != null)
                {
                    fastenerSource ed = new fastenerSource(lst);
                    if (ed != null)
                    {
                        edges.Add(ed);
                    }
                }
                if (faces.Count() == 0)
                {
                    break;
                }
                /*lst = */
            }
            cleanEdges();
        }
Пример #2
0
        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;
            }
        }