Ejemplo n.º 1
0
        void AddIds(Component2 component, Dictionary <Tuple <object, string, long?>, int> ids, ref int id)
        {
            if (component.IsHidden(true))
            {
                return;
            }

            var modelDoc = (IModelDoc2)component.GetModelDoc2();

            var tuple = GetTuple(component);

            if (ids.ContainsKey(tuple))
            {
                return;
            }

            ids[tuple] = id++;

            var assembly = modelDoc as IAssemblyDoc;

            if (assembly != null)
            {
                foreach (Component2 c in (object[])component.GetChildren())
                {
                    AddIds(c, ids, ref id);
                }
            }
        }
Ejemplo n.º 2
0
        private Boolean Decompter(Component2 cp)
        {
            try
            {
                if (!cp.IsHidden(true))
                {
                    foreach (var corps in cp.eListeCorps())
                    {
                        foreach (var face in corps.eListeDesFaces())
                        {
                            Surface S = face.GetSurface();
                            if (S.IsRef() && S.IsCylinder() && (face.GetLoopCount() > 1))
                            {
                                Double[] ListeParam = (Double[])S.CylinderParams;
                                Double   Diam       = Math.Round(ListeParam[6] * 2.0 * 1000, 2);

                                DicQte.AddIfNotExistOrPlus(Diam);
                            }
                        }
                    }
                }
            }
            catch (Exception e) { this.LogMethode(new Object[] { e }); }

            return(false);
        }
Ejemplo n.º 3
0
        //finds all the hidden components, which will be added to a new display state. Also
        // used when exporting STLs, so that hidden components remain hidden
        public static List <string> FindHiddenComponents(object[] varComp)
        {
            List <string> hiddenComp = new List <string>();

            foreach (object obj in varComp)
            {
                Component2 comp = (Component2)obj;
                if (comp.IsHidden(false))
                {
                    hiddenComp.Add(comp.Name2);
                }
            }
            return(hiddenComp);
        }
        private Boolean Maj(Component2 Cp)
        {
            if (!Cp.IsHidden(true) && !_Dic.ContainsKey(Cp.eKeyAvecConfig()) && Cp.eEstDansLeDossier(MdlBase) && (Cp.TypeDoc() == eTypeDoc.Piece))
            {
                _Dic.Add(Cp.eKeyAvecConfig(), "");

                WindowLog.Ecrire(Cp.eNomAvecExt());
                try
                {
                    PartDoc piece = Cp.ePartDoc();
                    piece.eInsererListeDesPiecesSoudees();
                    piece.eMajListeDesPiecesSoudees();
                }
                catch (Exception e)
                { this.LogMethode(new Object[] { e }); }
            }

            return(false);
        }
        private Boolean SupprimerConfigs(Component2 Cp)
        {
            try
            {
                if ((Cp.TypeDoc() == eTypeDoc.Piece) && !Cp.IsHidden(true) && !_Dic.ContainsKey(Cp.eKeySansConfig()) && Cp.eEstDansLeDossier(MdlBase))
                {
                    _Dic.Add(Cp.eKeySansConfig(), "");

                    WindowLog.Ecrire(Cp.eNomAvecExt());
                    foreach (Configuration Cf in Cp.eModelDoc2().eListeConfigs(eTypeConfig.Depliee))
                    {
                        String IsSup = Cf.eSupprimerConfigAvecEtatAff(Cp.eModelDoc2()) ? "Ok" : "Erreur";
                        WindowLog.EcrireF("  {0} : {1}", Cf.Name, IsSup);
                    }
                }
            }
            catch (Exception e)
            {
                this.LogErreur(new Object[] { e });
            }

            return(false);
        }
Ejemplo n.º 6
0
            public Boolean Decompter(Component2 cp)
            {
                try
                {
                    if (!cp.IsHidden(true))
                    {
                        foreach (var corps in cp.eListeCorps())
                        {
                            foreach (var face in corps.eListeDesFaces())
                            {
                                Surface S = face.GetSurface();
                                if (S.IsRef() && S.IsCylinder() && (face.GetLoopCount() > 1))
                                {
                                    // On regarde si c'est un trou ou un cylindre
                                    Double[] ListeParam = (Double[])S.CylinderParams;
                                    gPoint   Centre     = new gPoint(ListeParam[0], ListeParam[1], ListeParam[2]);
                                    gVecteur Axe        = new gVecteur(ListeParam[3], ListeParam[4], ListeParam[5]);
                                    Double   Diam       = Math.Round(ListeParam[6] * 2.0 * 1000, 2);

                                    Double[] FaceUV = face.GetUVBounds();
                                    Double[] Eval   = S.Evaluate(FaceUV[0], FaceUV[2], 0, 0);
                                    // Point de départ de la normale
                                    gPoint   PointNormale = new gPoint(Eval[0], Eval[1], Eval[2]);
                                    gVecteur Normale      = new gVecteur(Eval[3], Eval[4], Eval[5]);
                                    if (face.FaceInSurfaceSense())
                                    {
                                        Normale.Inverser();
                                    }

                                    gVecteur Vtest = new gVecteur(PointNormale, Centre);

                                    // Si l'angle est inférieur à 90°, la normale va vers le centre
                                    // donc c'est un trou
                                    if (Normale.Angle(Vtest) < D90)
                                    {
                                        var dicDiam = new Dictionary <Component2, List <Face2> >();
                                        if (Dic.ContainsKey(Diam))
                                        {
                                            dicDiam = Dic[Diam];
                                        }
                                        else
                                        {
                                            Dic.Add(Diam, dicDiam);
                                        }

                                        var listFace = new List <Face2>();
                                        if (dicDiam.ContainsKey(cp))
                                        {
                                            listFace = dicDiam[cp];
                                        }
                                        else
                                        {
                                            dicDiam.Add(cp, listFace);
                                        }

                                        listFace.Add(face);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e) { this.LogMethode(new Object[] { e }); }

                return(false);
            }
Ejemplo n.º 7
0
        public void OutputCompXformTemp(Component2 swComp, long nLevel, string parents)
        {
            object[]      vChild;
            Component2    swChildComp;
            string        sPadStr      = "";
            string        tempSelectID = "";
            MathTransform swCompXform;
            //  object vXform;
            long i;

            for (i = 0; i < nLevel; i++)
            {
                sPadStr = sPadStr + ".";
            }

            swCompXform = swComp.Transform2;

            if (swCompXform != null)
            {
                ModelDoc2 swModel;
                swModel = (ModelDoc2)swComp.GetModelDoc2();
                Boolean tempSupp = swComp.IsSuppressed();
                Boolean tempHide = swComp.IsHidden(false);

                if (swModel != null && tempSupp == false)
                {
                    StatusLab.Text = "Loading:" + swComp.Name;

                    string tempCode     = Path.GetFileNameWithoutExtension(swModel.GetPathName());
                    string swMateDB     = "";
                    string tempMaterial = "";
                    if (swModel.GetType() == 1)
                    {
                        tempMaterial = ((PartDoc)swModel).GetMaterialPropertyName2("", out swMateDB);
                    }
                    else
                    {
                        tempMaterial = "";
                    }

                    string tempSize = swModel.GetCustomInfoValue("", "零件尺寸");

                    string tempComment = swModel.GetCustomInfoValue("", "其它说明");

                    string tempblanktype = swModel.GetCustomInfoValue("", "下料方式");

                    string tempName = CodetoName(tempCode);

                    string tempName2 = GetName(tempCode);

                    tempSelectID = swComp.GetSelectByIDString();

                    int tempblanqty = 1;

                    if (ignore != "" && tempSelectID.Contains(ignore) == true)
                    {
                    }
                    else
                    {
                        var q = bomItems.Where(x => x.name == tempName && x.parents == parents).ToList();

                        if (q.Count == 0 && tempCode.Contains("镜向") == false && tempCode.Contains("复制") == false)
                        {
                            bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 1, "", tempComment, tempName, tempblanqty, tempName2, tempSelectID, parents, tempblanktype));
                        }
                        else if (tempCode.Contains("镜向"))
                        {
                            if (q.Count == 0)
                            {
                                if (sPadStr.Length == 1)
                                {
                                    bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 0, "", tempComment, tempName, 1, tempName, tempSelectID, parents, tempblanktype));
                                }

                                bomItems.Add(new BomItem(sPadStr, tempCode, "", "", 1, "", tempComment, "", 0, tempName2, tempSelectID, parents, tempblanktype));
                            }
                            else
                            {
                                if (bomItems[bomItems.IndexOf(q[0])].parents == parents)
                                {
                                    bomItems[bomItems.IndexOf(q[0])].blankqty = bomItems[bomItems.IndexOf(q[0])].blankqty + 1;

                                    //	bomItems[bomItems.IndexOf(q[0])] = new BomItem(sPadStr, bomItems[bomItems.IndexOf(q[0])].code, bomItems[bomItems.IndexOf(q[0])].material, bomItems[bomItems.IndexOf(q[0])].size, bomItems[bomItems.IndexOf(q[0])].qty, bomItems[bomItems.IndexOf(q[0])].blanksize, tempComment, bomItems[bomItems.IndexOf(q[0])].name, bomItems[bomItems.IndexOf(q[0])].blankqty + 1, bomItems[bomItems.IndexOf(q[0])].name2);

                                    var q2 = bomItems.Where(x => x.name2 == tempName2).ToList();

                                    if (q2.Count == 0)
                                    {
                                        //bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 0, tempBlankSize, tempComment, tempName, 0, tempName2));
                                        bomItems.Add(new BomItem(sPadStr, tempCode, "", "", 1, "", tempComment, "", 0, tempName2, tempSelectID, parents, tempblanktype));
                                    }
                                    else
                                    {
                                        bomItems[bomItems.IndexOf(q2[0])].qty = bomItems[bomItems.IndexOf(q2[0])].qty + 1;
                                    }
                                }
                                else
                                {
                                    bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 1, "", tempComment, tempName, tempblanqty, tempName2, tempSelectID, parents, tempblanktype));
                                }
                            }
                        }
                        else if (tempCode.Contains("复制"))
                        {
                            if (q.Count == 0)
                            {
                                bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 1, "", tempComment, tempName, 1, tempName, tempSelectID, parents, tempblanktype));
                            }
                            else
                            {
                                bomItems[bomItems.IndexOf(q[0])].qty      = bomItems[bomItems.IndexOf(q[0])].qty + 1;
                                bomItems[bomItems.IndexOf(q[0])].blankqty = bomItems[bomItems.IndexOf(q[0])].blankqty + 1;

                                if (swModel.GetType() == 2)
                                {
                                    ignore = tempSelectID;
                                }
                            }
                        }
                        else if (q.Count > 0 && tempCode.Contains("镜向") == false && tempCode.Contains("复制") == false && bomItems[bomItems.IndexOf(q[0])].parents == parents)
                        {
                            bomItems[bomItems.IndexOf(q[0])].qty      = bomItems[bomItems.IndexOf(q[0])].qty + 1;
                            bomItems[bomItems.IndexOf(q[0])].blankqty = bomItems[bomItems.IndexOf(q[0])].blankqty + 1;

                            if (swModel.GetType() == 2)
                            {
                                ignore = tempSelectID;
                            }
                        }
                        else
                        {
                            bomItems.Add(new BomItem(sPadStr, tempCode, tempMaterial, tempSize, 1, "", tempComment, tempName, tempblanqty, tempName2, tempSelectID, parents, tempblanktype));
                        }
                    }
                }
            }
            ;

            vChild = (object[])swComp.GetChildren();

            for (i = 0; i <= (vChild.Length - 1); i++)
            {
                swChildComp = (Component2)vChild[i];

                OutputCompXformTemp(swChildComp, nLevel + 1, tempSelectID);

                if (i == vChild.Length - 1)
                {
                    ignore = "";
                }
            }
        }