コード例 #1
0
        protected Boolean SelectFace(CtrlSelectionBox SelBox, Component2 Cp, Parametre param)
        {
            if (Cp.IsNull())
            {
                return(false);
            }

            String cFace = param.GetValeur <String>();
            Face2  Face  = Cp.eChercherFace(cFace);

            if (Face.IsRef())
            {
                MdlBase.eSelectMulti(Face, SelBox.Marque, true);
            }

            return(true);
        }
コード例 #2
0
        private void Run(Component2 cBase)
        {
            if (cBase == null)
            {
                this.LogMethode(new String[] { _NomConfigActive });
                this.LogMethode(new String[] { "Une reference à un objet a été perdue cBase :", cBase.IsRefToString() });
                return;
            }

            try
            {
                List <Body2> ListeCorps = cBase.eListeCorps();
                List <Face2> ListeFace  = new List <Face2>();

                // Recherche des faces cylindriques
                foreach (Body2 C in ListeCorps)
                {
                    foreach (Face2 F in C.eListeDesFaces())
                    {
                        Surface S = F.GetSurface();
                        if (S.IsCylinder())
                        {
                            if (PercageOuvert || (F.GetLoopCount() > 1))
                            {
                                // Si le diametre == 0 on recupère toutes les faces
                                if ((ListeDiametre.Count == 1) && (ListeDiametre[0] == 0))
                                {
                                    if ((Face == null) || (F.eListeDesFacesContigues().Contains(Face)))
                                    {
                                        ListeFace.Add(F);
                                    }
                                }
                                // Sinon, on verifie qu'elle corresponde bien au diametre demandé
                                else
                                {
                                    Double[] ListeParam = (Double[])S.CylinderParams;
                                    Double   Diam       = Math.Round(ListeParam[6] * 2.0 * 1000, 2);

                                    if (ListeDiametre.Contains(Diam))
                                    {
                                        if ((Face == null) || (F.eListeDesFacesContigues().Contains(Face)))
                                        {
                                            ListeFace.Add(F);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // S'il n'y a pas assez de composant de perçage, on en rajoute
                while (_ListePercage.Count < ListeFace.Count)
                {
                    AjouterPercage();
                }

                _MdlBase.EditRebuild3();

                // Mise à jour des références des perçages
                //ReinitialiserRefListe(ref _ListePercage);

                List <String> ListeComp = new List <String>();
                if (!_DicConfigWithComp.ContainsKey(_NomConfigActive))
                {
                    _DicConfigWithComp.Add(_NomConfigActive, ListeComp);
                }
                else
                {
                    ListeComp = _DicConfigWithComp[_NomConfigActive];
                }


                List <String> ListeNomComp = _ListePercage.Keys.ToList();

                // Contrainte des perçages
                for (int i = 0; i < ListeFace.Count; i++)
                {
                    String     NomComp = ListeNomComp[i];
                    Component2 Comp    = _AssBase.GetComponentByName(NomComp);
                    // On active le composant au cas ou :)

                    _MdlBase.eSelectByIdComp(_ListePercage[NomComp]);
                    _AssBase.eModifierEtatComposant(swComponentSuppressionState_e.swComponentResolved);
                    _MdlBase.eEffacerSelection();

                    Face2 Cylindre = ListeFace[i];

                    ListeComp.Add(NomComp);

                    //DesactiverContrainte(Comp);

                    _MdlBase.ClearSelection2(true);

                    if (Plan.IsRef())
                    {
                        Plan.eSelect();
                    }
                    else if (Face.IsRef())
                    {
                        Face.eSelectEntite();
                    }
                    else
                    {
                        Face2 FaceContrainte = FacePlane(Cylindre);

                        // Si on trouve une face pour la contrainte, on sélectionne
                        // Sinon, on passe au trou suivant
                        if (FaceContrainte.IsRef())
                        {
                            FaceContrainte.eSelectEntite();
                        }
                        else
                        {
                            continue;
                        }
                    }

                    Feature fPlan = PlanContrainte(Comp);

                    if (fPlan == null)
                    {
                        this.LogMethode(new String[] { "Pas de \"Plan de face\"" });
                        continue;
                    }

                    fPlan.eSelect(true);

                    int longstatus = 0;
                    _AssBase.AddMate5((int)swMateType_e.swMateCOINCIDENT,
                                      (int)swMateAlign_e.swMateAlignCLOSEST,
                                      false,
                                      0, 0, 0, 0, 0, 0, 0, 0,
                                      false, false, 0, out longstatus);

                    _MdlBase.eEffacerSelection();

                    Cylindre.eSelectEntite();

                    Face2 fFace = FaceCylindrique(Comp);

                    fFace.eSelectEntite(true);

                    _AssBase.AddMate5((int)swMateType_e.swMateCONCENTRIC,
                                      (int)swMateAlign_e.swMateAlignCLOSEST,
                                      false,
                                      0, 0, 0, 0, 0, 0, 0, 0,
                                      false, true, 0, out longstatus);

                    _MdlBase.eEffacerSelection();
                }
            }
            catch (Exception e)
            {
                this.LogMethode(new Object[] { e });
            }
        }