public void SelectContraintes()
            {
                try
                {
                    EffacerContraintes();

                    Component2 cpMarche    = MdlBase.eSelect_RecupererComposant(1, _Select_Marche.Marque);
                    Feature    fRepet      = MdlBase.eSelect_RecupererObjet <Feature>(1, _Select_FonctionRepet.Marque);
                    Component2 cpRepet     = MdlBase.eSelect_RecupererComposant(1, _Select_FonctionRepet.Marque);
                    Object[]   Contraintes = cpMarche.GetMates();

                    if (cpMarche.IsNull() || fRepet.IsNull() || cpRepet.IsNull() || Contraintes.IsNull())
                    {
                        return;
                    }

                    CurveDrivenPatternFeatureData def = fRepet.GetDefinition();
                    Object[] tabB = def.PatternBodyArray;
                    Body2    b    = (Body2)tabB[0];

                    foreach (Mate2 m in Contraintes)
                    {
                        MateEntity2 m1 = m.MateEntity(0);
                        MateEntity2 m2 = m.MateEntity(1);

                        if (AppartientAuCorps(cpRepet, b, m1))
                        {
                            if ((m1.ReferenceType2 == (int)swSelectType_e.swSelVERTICES) && PointCorps.IsNull())
                            {
                                PointCorps  = m1.Reference;
                                PointMarche = m2.Reference;
                            }
                            else if ((m1.ReferenceType2 == (int)swSelectType_e.swSelEDGES) && ArreteCorps.IsNull())
                            {
                                ArreteCorps = m1.Reference;
                                AxeMarche   = m2.Reference;
                            }
                        }
                        else if (AppartientAuComposant(cpRepet, m1) && (m1.ReferenceType2 == (int)swSelectType_e.swSelDATUMPLANES) && PlanComp.IsNull())
                        {
                            PlanComp   = m1.Reference;
                            PlanMarche = m2.Reference;
                        }
                        else if (AppartientAuCorps(cpRepet, b, m2))
                        {
                            if ((m2.ReferenceType2 == (int)swSelectType_e.swSelVERTICES) && PointCorps.IsNull())
                            {
                                PointCorps  = m2.Reference;
                                PointMarche = m1.Reference;
                            }
                            else if ((m2.ReferenceType2 == (int)swSelectType_e.swSelEDGES) && ArreteCorps.IsNull())
                            {
                                ArreteCorps = m2.Reference;
                                AxeMarche   = m1.Reference;
                            }
                        }
                        else if (AppartientAuComposant(cpRepet, m2) && (m2.ReferenceType2 == (int)swSelectType_e.swSelDATUMPLANES) && PlanComp.IsNull())
                        {
                            PlanComp   = m2.Reference;
                            PlanMarche = m1.Reference;
                        }
                    }

                    MdlBase.eSelectMulti(PointCorps, _Select_Contraintes_PointCorps.Marque, true);
                    MdlBase.eSelectMulti(PointMarche, _Select_Contraintes_PointMarche.Marque, true);
                    MdlBase.eSelectMulti(ArreteCorps, _Select_Contraintes_ArreteCorps.Marque, true);
                    MdlBase.eSelectMulti(AxeMarche, _Select_Contraintes_AxeMarche.Marque, true);
                    MdlBase.eSelectMulti(PlanComp, _Select_Contraintes_PlanComp.Marque, true);
                    MdlBase.eSelectMulti(PlanMarche, _Select_Contraintes_PlanMarche.Marque, true);

                    ContraintesVide = false;
                }
                catch (Exception e)
                { this.LogMethode(new Object[] { e }); }
            }
            protected override void Command()
            {
                Ass = MdlBase.eAssemblyDoc();

                try
                {
                    CurveDrivenPatternFeatureData def = FonctionRepetition.GetDefinition();
                    Object[] tabB = def.PatternBodyArray;
                    Body2    b    = (Body2)tabB[0];

                    MathTransform compRepetTrans  = ComposantRepetition.Transform2;
                    MathTransform baseMarcheTrans = Marche.Transform2;

                    Vertex v = (Vertex)Point;
                    Edge   e = (Edge)Arrete;

                    List <Face2> ListeFace = FonctionRepetition.eListeDesFaces();

                    Sketch  sk           = PointMarche.GetSketch();
                    Feature fPointMarche = (Feature)sk;

                    List <Component2> ListeComposants = new List <Component2>()
                    {
                        Marche
                    };

                    Double arr = 0.0001;

                    for (int i = 1; i <= (def.D1InstanceCount + def.D2InstanceCount); i++)
                    {
                        MathTransform bodyTrans = def.GetTransform(i);
                        if (bodyTrans.IsNull())
                        {
                            break;
                        }

                        MathTransform Transform = compRepetTrans.Inverse();
                        Transform = Transform.Multiply(bodyTrans);
                        Transform = Transform.Multiply(compRepetTrans);
                        Transform = baseMarcheTrans.Multiply(Transform);

                        gPoint   pt = new gPoint(v);
                        gSegment sg = new gSegment(e);
                        pt.MultiplyTransfom(bodyTrans);
                        sg.MultiplyTransfom(bodyTrans);

                        Vertex vertex = null;
                        Edge   edge   = null;

                        foreach (Face2 face in ListeFace)
                        {
                            foreach (Edge ed in face.eListeDesArretes())
                            {
                                gSegment s = new gSegment(ed);

                                if (sg.Compare(s, arr))
                                {
                                    edge = ed;
                                }

                                if (s.Start.Comparer(pt, arr))
                                {
                                    vertex = ed.GetStartVertex();
                                }

                                if (s.End.Comparer(pt, arr))
                                {
                                    vertex = ed.GetEndVertex();
                                }

                                if (edge.IsRef() && vertex.IsRef())
                                {
                                    break;
                                }
                            }

                            if (edge.IsRef() && vertex.IsRef())
                            {
                                break;
                            }
                        }

                        Entity eVertex = (Entity)vertex;
                        Entity eEdge   = (Entity)edge;

                        Component2 cp = Ass.AddComponent5(Marche.GetPathName(), (int)swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", false, "", 0, 0, 0);
                        if (cp.IsNull())
                        {
                            continue;
                        }

                        // Quand on réinsere un composant, les précédentes contraintes sont recrées.
                        // On les supprime pour eviter des conflits
                        Object[] Mates = cp.GetMates();

                        if (Mates.IsRef())
                        {
                            foreach (Feature mate in Mates)
                            {
                                mate.eSelect();
                                MdlBase.Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Absorbed);
                            }
                        }

                        WindowLog.Ecrire(cp.Name2);

                        cp.Transform2 = Transform;
                        ListeComposants.Add(cp);

                        int longstatus = 0;

                        MdlBase.eEffacerSelection();
                        eVertex.eSelectEntite(false);
                        Feature     f             = cp.FeatureByName(fPointMarche.Name);
                        Sketch      sketchOrigine = f.GetSpecificFeature2();
                        Object[]    tabPt         = sketchOrigine.GetSketchPoints2();
                        SketchPoint origine       = (SketchPoint)tabPt[0];
                        origine.Select4(true, null);
                        Mate2 mPoint = Ass.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();

                        MdlBase.eEffacerSelection();
                        eEdge.eSelectEntite(false);
                        cp.FeatureByName(AxeMarche.Name).eSelect(true);
                        Mate2 mAxe = Ass.AddMate5((int)swMateType_e.swMateANGLE,
                                                  (int)swMateAlign_e.swAlignNONE, false, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0, out longstatus);
                        MdlBase.eEffacerSelection();

                        MdlBase.eEffacerSelection();
                        Plan.eSelect(false);
                        cp.FeatureByName(PlanMarche.Name).eSelect(true);
                        Mate2 mPlan = Ass.AddMate5((int)swMateType_e.swMatePARALLEL,
                                                   (int)swMateAlign_e.swAlignNONE, false, 0, 0, 0, 0, 0, 0, 0, 0, false, false, 0, out longstatus);
                        MdlBase.eEffacerSelection();

                        Feature m = (Feature)mPoint;
                        WindowLog.Ecrire("   " + m.Name);
                        m = (Feature)mAxe;
                        WindowLog.Ecrire("   " + m.Name);
                        m = (Feature)mPlan;
                        WindowLog.Ecrire("   " + m.Name);
                    }

                    MdlBase.eEffacerSelection();

                    foreach (var cp in ListeComposants)
                    {
                        cp.eSelectById(MdlBase, -1, true);
                    }

                    Feature Dossier = MdlBase.FeatureManager.InsertFeatureTreeFolder2((int)swFeatureTreeFolderType_e.swFeatureTreeFolder_Containing);
                    Dossier.eRenommerFonction(String.Format("Marches ({0} {1}) ", ComposantRepetition.Name2, FonctionRepetition.Name));
                }
                catch (Exception e)
                {
                    this.LogErreur(new Object[] { e });
                }
            }