private void Run(Component2 Comp) { try { List <Feature> ListePlanRef; if (CompBase.IsNull()) { ListePlanRef = MdlBase.eListeFonctions(f => { return(f.GetTypeName2() == FeatureType.swTnRefPlane); }); } else { ListePlanRef = CompBase.eListeFonctions(f => { return(f.GetTypeName2() == FeatureType.swTnRefPlane); }); } Log.Message(Comp.Name2); List <Feature> ListePlan = Comp.eListeFonctions(f => { return(f.GetTypeName2() == FeatureType.swTnRefPlane); }); Boolean EstFixe = Comp.IsFixed(); Comp.eLiberer(_Ass); Mate2 FxContrainte = null; int Erreur = 0; for (int i = 0; i < Math.Min(3, Math.Min(ListePlanRef.Count, ListePlan.Count)); i++) { Feature PlanRef = ListePlanRef[i]; Feature Plan = ListePlan[i]; PlanRef.eSelectionnerById2(MdlBase, -1, false); Plan.eSelectionnerById2(MdlBase, -1, true); FxContrainte = _Ass.AddMate5((int)swMateType_e.swMateCOINCIDENT, (int)swMateAlign_e.swMateAlignALIGNED, false, 0, 0, 0, 0, 0, 0, 0, 0, false, true, 0, out Erreur); } MdlBase.eEffacerSelection(); if (EstFixe || FixerComposant) { Comp.eFixer(_Ass); } } catch (Exception e) { this.LogErreur(new Object[] { e }); } }
protected Boolean SelectEsquisse(CtrlSelectionBox SelBox, Component2 Cp, Parametre param) { if (Cp.IsNull()) { return(false); } String cEsquisseConfig = param.GetValeur <String>(); Feature Esquisse = Cp.eChercherFonction(f => { return(Regex.IsMatch(f.Name, cEsquisseConfig)); }, true); if (Esquisse.IsRef()) { MdlBase.eSelectMulti(Esquisse, SelBox.Marque, true); } return(true); }
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); }
protected Boolean SelectPlan(CtrlSelectionBox SelBox, Component2 Cp, Parametre param) { if (Cp.IsNull()) { return(false); } String cPlanContrainte = param.GetValeur <String>(); Feature Plan = Cp.eChercherFonction(f => { return(Regex.IsMatch(f.Name, cPlanContrainte)); }, false); if (Plan.IsRef()) { MdlBase.eSelectMulti(Plan, SelBox.Marque, true); } return(false); }
/// <summary> /// Creer un percage ou ajouter /// </summary> /// <param name="comp"></param> private void AjouterPercage(Component2 comp = null) { Component2 Comp = comp; if (comp.IsNull()) { Comp = _AssBase.AddComponent5(CompPercage.GetPathName(), (int)swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", true, CompPercage.eNomConfiguration(), 0, 0, 0); } _MdlBase.eSelectByIdComp(Comp.GetSelectByIDString()); _AssBase.eModifierEtatComposant(swComponentSuppressionState_e.swComponentResolved); _MdlBase.eEffacerSelection(); _ListePercage.Add(Comp.Name2, Comp.GetSelectByIDString()); }
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 }); } }