コード例 #1
0
        private String GetMateriauCorpsBase(Body2 corpsBase, Component2 cpCorpsBase)
        {
            String materiauxCorpsBase = "";

            if (MdlBase.TypeDoc() == eTypeDoc.Piece)
            {
                materiauxCorpsBase = corpsBase.eGetMateriauCorpsOuPiece(MdlBase.ePartDoc(), MdlBase.eNomConfigActive());
            }
            else
            {
                materiauxCorpsBase = corpsBase.eGetMateriauCorpsOuComp(cpCorpsBase);
            }

            return(materiauxCorpsBase);
        }
コード例 #2
0
        protected override void Command()
        {
            try
            {
                Face2 Face = MdlBase.eSelect_RecupererObjet <Face2>();
                if (Face.IsNull())
                {
                    WindowLog.Ecrire("Pas de face selectionnée");
                    return;
                }

                Body2 CorpsBase = Face.GetBody();
                if (CorpsBase.IsNull())
                {
                    WindowLog.Ecrire("Pas de corps selectionnée");
                    return;
                }

                String MateriauxCorpsBase = "";

                if (MdlBase.TypeDoc() == eTypeDoc.Piece)
                {
                    MateriauxCorpsBase = CorpsBase.eGetMateriauCorpsOuPiece(MdlBase.ePartDoc(), MdlBase.eNomConfigActive());
                }
                else
                {
                    Component2 cpCorpsBase = MdlBase.eSelect_RecupererComposant();
                    MateriauxCorpsBase = CorpsBase.eGetMateriauCorpsOuComp(cpCorpsBase);
                }

                MdlBase.eEffacerSelection();

                WindowLog.Ecrire("Matériau : " + MateriauxCorpsBase);

                var ListeCorpsIdentiques = new List <Body2>();

                Action <Body2, String> Test = delegate(Body2 corps, String mat)
                {
                    if (MateriauxCorpsBase != mat)
                    {
                        return;
                    }

                    if (corps.eComparerGeometrie(CorpsBase) == Sw.Comparaison_e.Semblable)
                    {
                        ListeCorpsIdentiques.Add(corps);
                    }
                };

                if (MdlBase.TypeDoc() == eTypeDoc.Piece)
                {
                    var Piece = MdlBase.ePartDoc();
                    foreach (var Corps in Piece.eListeCorps())
                    {
                        var MateriauCorpsTest = Corps.eGetMateriauCorpsOuPiece(Piece, MdlBase.eNomConfigActive());
                        Test(Corps, MateriauCorpsTest);
                    }
                }
                else
                {
                    foreach (var comp in MdlBase.eComposantRacine().eRecListeComposant(c => { return(c.TypeDoc() == eTypeDoc.Piece); }))
                    {
                        foreach (var Corps in comp.eListeCorps())
                        {
                            var MateriauCorpsTest = Corps.eGetMateriauCorpsOuComp(comp);
                            Test(Corps, MateriauCorpsTest);
                        }
                    }
                }

                WindowLog.EcrireF("Nb de corps identiques : {0}", ListeCorpsIdentiques.Count);
                foreach (var corps in ListeCorpsIdentiques)
                {
                    corps.eSelect(true);
                }
            }
            catch (Exception e)
            {
                this.LogErreur(new Object[] { e });
            }
        }
コード例 #3
0
        protected override void Command()
        {
            CreerDossierDVP();

            WindowLog.Ecrire(String.Format("Dossier :\r\n{0}", new DirectoryInfo(DossierExport).Name));

            try
            {
                eTypeCorps       Filtre        = PrendreEnCompteTole ? eTypeCorps.Barre | eTypeCorps.Tole : eTypeCorps.Barre;
                HashSet <String> HashMateriaux = new HashSet <string>(ListeMateriaux);

                var dic = MdlBase.DenombrerDossiers(ComposantsExterne,
                                                    fDossier =>
                {
                    BodyFolder swDossier = fDossier.GetSpecificFeature2();

                    if (Filtre.HasFlag(swDossier.eTypeDeDossier()) && HashMateriaux.Contains(swDossier.eGetMateriau()))
                    {
                        return(true);
                    }

                    return(false);
                }
                                                    );

                if (ListerUsinages)
                {
                    Nomenclature.TitreColonnes("Barre ref.", "Materiau", "Profil", "Lg", "Nb", "Usinage Ext 1", "Usinage Ext 2", "Détail des Usinage interne");
                }
                else
                {
                    Nomenclature.TitreColonnes("Barre ref.", "Materiau", "Profil", "Lg", "Nb");
                }

                int MdlPct = 0;
                foreach (var mdl in dic.Keys)
                {
                    mdl.eActiver(swRebuildOnActivation_e.swRebuildActiveDoc);

                    WindowLog.SautDeLigne();
                    WindowLog.EcrireF("[{1}/{2}] {0}", mdl.eNomSansExt(), ++MdlPct, dic.Count);

                    int CfgPct = 0;
                    foreach (var NomConfigPliee in dic[mdl].Keys)
                    {
                        WindowLog.SautDeLigne();
                        WindowLog.EcrireF("  [{1}/{2}] Config : \"{0}\"", NomConfigPliee, ++CfgPct, dic[mdl].Count);
                        mdl.ShowConfiguration2(NomConfigPliee);
                        mdl.EditRebuild3();
                        PartDoc Piece = mdl.ePartDoc();

                        var ListeDossier = dic[mdl][NomConfigPliee];
                        int DrPct        = 0;
                        foreach (var t in ListeDossier)
                        {
                            var IdDossier     = t.Key;
                            var QuantiteBarre = t.Value * Quantite;

                            Feature    fDossier = Piece.FeatureById(IdDossier);
                            BodyFolder dossier  = fDossier.GetSpecificFeature2();

                            var RefDossier = dossier.eProp(CONSTANTES.REF_DOSSIER);

                            Body2 Barre = dossier.ePremierCorps();

                            String Profil   = dossier.eProp(CONSTANTES.PROFIL_NOM);
                            String Longueur = dossier.eProp(CONSTANTES.PROFIL_LONGUEUR);

                            String Materiau = Barre.eGetMateriauCorpsOuPiece(Piece, NomConfigPliee);

                            Materiau = ForcerMateriau.IsRefAndNotEmpty(Materiau);

                            String NomFichierBarre = ConstruireNomFichierBarre(RefDossier, QuantiteBarre);

                            WindowLog.SautDeLigne();
                            WindowLog.EcrireF("    - [{1}/{2}] Dossier : \"{0}\" x{3}", RefDossier, ++DrPct, ListeDossier.Count, QuantiteBarre);
                            WindowLog.EcrireF("              Profil {0}  Materiau {1}", Profil, Materiau);

                            List <String> Liste = new List <String>()
                            {
                                RefDossier, Materiau, Profil, Math.Round(Longueur.eToDouble()).ToString(), "× " + QuantiteBarre.ToString()
                            };

                            if (ListerUsinages)
                            {
                                var analyse = new AnalyseBarre(Barre, mdl);

                                Dictionary <String, Double> Dic = new Dictionary <string, double>();

                                foreach (var u in analyse.ListeFaceUsinageSection)
                                {
                                    String nom = u.ListeFaceDecoupe.Count + " face - Lg " + Math.Round(u.LgUsinage * 1000, 1);
                                    if (Dic.ContainsKey(nom))
                                    {
                                        Dic[nom] += 1;
                                    }
                                    else
                                    {
                                        Dic.Add(nom, 1);
                                    }
                                }

                                Liste.Add(Math.Round(analyse.ListeFaceUsinageExtremite[0].LgUsinage * 1000, 1).ToString());

                                if (analyse.ListeFaceUsinageExtremite.Count > 1)
                                {
                                    Liste.Add(Math.Round(analyse.ListeFaceUsinageExtremite[1].LgUsinage * 1000, 1).ToString());
                                }
                                else
                                {
                                    Liste.Add("");
                                }

                                foreach (var nom in Dic.Keys)
                                {
                                    Liste.Add(Dic[nom] + "x [ " + nom + " ]");
                                }
                            }

                            Nomenclature.AjouterLigne(Liste.ToArray());

                            if (ExporterBarres)
                            {
                                //mdl.ViewZoomtofit2();
                                //mdl.ShowNamedView2("*Isométrique", 7);
                                String    CheminFichier;
                                ModelDoc2 mdlBarre = Barre.eEnregistrerSous(Piece, DossierExport, NomFichierBarre, TypeExport, out CheminFichier);

                                if (CreerPdf3D)
                                {
                                    String CheminPDF = Path.Combine(DossierExportPDF, NomFichierBarre + eTypeFichierExport.PDF.GetEnumInfo <ExtFichier>());
                                    mdlBarre.SauverEnPdf3D(CheminPDF);
                                }

                                mdlBarre.eFermer();
                            }
                        }
                    }

                    mdl.eFermerSiDifferent(MdlBase);
                }

                WindowLog.SautDeLigne();
                WindowLog.Ecrire(Nomenclature.ListeLignes());

                CheminNomenclature = Path.Combine(DossierExport, "Nomenclature.txt");
                StreamWriter s = new StreamWriter(CheminNomenclature);
                s.Write(Nomenclature.GenererTableau());
                s.Close();
            }
            catch (Exception e) { this.LogErreur(new Object[] { e }); }
        }
コード例 #4
0
ファイル: Test1.cs プロジェクト: Titifonky/SwExtension
        protected override void Command()
        {
            try
            {
                Body2  CorpsBase         = null;
                String MateriauCorpsBase = "";
                if (MdlBase.eSelect_RecupererTypeObjet() == e_swSelectType.swSelFACES)
                {
                    var face = MdlBase.eSelect_RecupererObjet <Face2>();
                    CorpsBase = face.GetBody();
                }
                else if (MdlBase.eSelect_RecupererTypeObjet() == e_swSelectType.swSelSOLIDBODIES)
                {
                    CorpsBase = MdlBase.eSelect_RecupererObjet <Body2>();
                }

                if (CorpsBase == null)
                {
                    System.Windows.Forms.MessageBox.Show("Erreur de corps selectionné");
                    return;
                }

                MateriauCorpsBase = CorpsBase.eGetMateriauCorpsOuPiece(MdlBase.ePartDoc(), MdlBase.eNomConfigActive());

                System.Windows.Forms.OpenFileDialog pDialogue = new System.Windows.Forms.OpenFileDialog
                {
                    Filter           = "Fichier texte (*.data)|*.data|Tout les fichiers (*.*)|*.*",
                    Multiselect      = false,
                    InitialDirectory = Path.GetDirectoryName(Path.Combine(MdlBase.GetPathName(), "Pieces", "Corps")),
                    RestoreDirectory = true
                };

                String Chemin = "";

                if (pDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Chemin = pDialogue.FileName;
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Erreur de chemin");
                    return;
                }

                Body2  CorpsCharge         = null;
                String MateriauCorpsCharge = "";
                String NoCorps             = "";
                Byte[] Tab = File.ReadAllBytes(Chemin);
                using (MemoryStream ms = new MemoryStream(Tab))
                {
                    ManagedIStream MgIs = new ManagedIStream(ms);
                    Modeler        mdlr = (Modeler)App.Sw.GetModeler();
                    CorpsCharge = (Body2)mdlr.Restore(MgIs);
                }

                if (CorpsCharge == null)
                {
                    System.Windows.Forms.MessageBox.Show("Erreur de corps chargé");
                    return;
                }

                NoCorps = Path.GetFileNameWithoutExtension(Chemin).Substring(1);

                System.Windows.Forms.MessageBox.Show("NoCorps : " + NoCorps);

                var cheminNomenclature = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Chemin)), "Nomenclature.txt");

                System.Windows.Forms.MessageBox.Show("Chemin Nomenclature : " + cheminNomenclature);

                using (var sr = new StreamReader(cheminNomenclature, Encoding.GetEncoding(1252)))
                {
                    // On lit la première ligne contenant l'entête des colonnes
                    String ligne = sr.ReadLine();

                    if (ligne.IsRef())
                    {
                        while ((ligne = sr.ReadLine()) != null)
                        {
                            if (!String.IsNullOrWhiteSpace(ligne))
                            {
                                var tab = ligne.Split(new char[] { '\t' });
                                if (NoCorps == tab[0])
                                {
                                    MateriauCorpsCharge = tab[4];
                                    break;
                                }
                            }
                        }
                    }
                }

                if (String.IsNullOrWhiteSpace(MateriauCorpsCharge))
                {
                    System.Windows.Forms.MessageBox.Show("Erreur de materiau corps chargé");
                    return;
                }

                var Result = "Est different";
                if (MateriauCorpsCharge == MateriauCorpsBase)
                {
                    Result = "Est semblable";
                }

                System.Windows.Forms.MessageBox.Show("Materiau : " + MateriauCorpsCharge + " " + MateriauCorpsBase + "  " + Result);

                Result = "Est different";
                if (CorpsBase.eComparerGeometrie(CorpsCharge) == Sw.Comparaison_e.Semblable)
                {
                    Result = "Est semblable";
                }

                System.Windows.Forms.MessageBox.Show("Corps : " + Result);
            }
            catch (Exception e)
            {
                this.LogMethode(new Object[] { e });
            }
        }
コード例 #5
0
        protected override void Command()
        {
            try
            {
                if (ConvertirEsquisse)
                {
                    WindowLog.Ecrire("Attention !!!");
                    WindowLog.Ecrire("Les dvp seront convertis en esquisse");
                    WindowLog.SautDeLigne();
                }

                CreerDossierDVP();

                eTypeCorps       Filtre        = eTypeCorps.Tole;
                HashSet <String> HashMateriaux = new HashSet <string>(ListeMateriaux);
                HashSet <String> HashEp        = new HashSet <string>(ListeEp);

                var dic = MdlBase.DenombrerDossiers(ComposantsExterne,
                                                    fDossier =>
                {
                    BodyFolder swDossier = fDossier.GetSpecificFeature2();

                    if (Filtre.HasFlag(swDossier.eTypeDeDossier()) && HashMateriaux.Contains(swDossier.eGetMateriau()))
                    {
                        String Ep = swDossier.ePremierCorps().eEpaisseurCorps().ToString();

                        if (HashEp.Contains(Ep))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }
                                                    );

                int MdlPct = 0;
                foreach (var mdl in dic.Keys)
                {
                    mdl.eActiver(swRebuildOnActivation_e.swRebuildActiveDoc);

                    WindowLog.SautDeLigne();
                    WindowLog.EcrireF("[{1}/{2}] {0}", mdl.eNomSansExt(), ++MdlPct, dic.Count);


                    int CfgPct = 0;
                    foreach (var NomConfigPliee in dic[mdl].Keys)
                    {
                        WindowLog.SautDeLigne();
                        WindowLog.EcrireF("  [{1}/{2}] Config : \"{0}\"", NomConfigPliee, ++CfgPct, dic[mdl].Count);
                        mdl.ShowConfiguration2(NomConfigPliee);
                        mdl.EditRebuild3();
                        PartDoc Piece = mdl.ePartDoc();

                        var ListeDossier = dic[mdl][NomConfigPliee];
                        int DrPct        = 0;
                        foreach (var t in ListeDossier)
                        {
                            var IdDossier    = t.Key;
                            var QuantiteTole = t.Value * Quantite;

                            Feature    fDossier = Piece.FeatureById(IdDossier);
                            BodyFolder dossier  = fDossier.GetSpecificFeature2();

                            var RefDossier = dossier.eProp(CONSTANTES.REF_DOSSIER);

                            Body2 Tole = dossier.eCorpsDeTolerie();

                            WindowLog.SautDeLigne();
                            WindowLog.EcrireF("    - [{1}/{2}] Dossier : \"{0}\" x{3}", RefDossier, ++DrPct, ListeDossier.Count, QuantiteTole);

                            String Materiau = Tole.eGetMateriauCorpsOuPiece(Piece, NomConfigPliee);

                            Materiau = ForcerMateriau.IsRefAndNotEmpty(Materiau);

                            Double Epaisseur        = Tole.eEpaisseurCorps();
                            String NomConfigDepliee = Sw.eNomConfigDepliee(NomConfigPliee, RefDossier);

                            WindowLog.EcrireF("      Ep {0} / Materiau {1}", Epaisseur, Materiau);
                            WindowLog.EcrireF("          Config {0}", NomConfigDepliee);

                            if (ConvertirEsquisse)
                            {
                                if (!mdl.eListeNomConfiguration().Contains(NomConfigDepliee))
                                {
                                    mdl.CreerConfigDepliee(NomConfigDepliee, NomConfigPliee);
                                }

                                WindowLog.EcrireF("          Configuration crée : {0}", NomConfigDepliee);
                                mdl.ShowConfiguration2(NomConfigDepliee);
                                Tole.DeplierTole(mdl, NomConfigDepliee);
                            }
                            else if (!mdl.ShowConfiguration2(NomConfigDepliee))
                            {
                                DicErreur.Add(mdl.eNomSansExt() + " -> cfg : " + NomConfigPliee + " - No : " + RefDossier + " = " + NomConfigDepliee);
                                WindowLog.EcrireF("La configuration n'éxiste pas");
                                continue;
                            }

                            mdl.EditRebuild3();

                            DrawingDoc dessin = CreerPlan(Materiau, Epaisseur);
                            dessin.eModelDoc2().eActiver();
                            Sheet Feuille = dessin.eFeuilleActive();

                            View v = CreerVueToleDvp(dessin, Feuille, Piece, NomConfigDepliee, RefDossier, Materiau, QuantiteTole, Epaisseur);

                            if (ConvertirEsquisse)
                            {
                                mdl.ShowConfiguration2(NomConfigPliee);
                                mdl.EditRebuild3();
                                mdl.DeleteConfiguration2(NomConfigDepliee);
                            }
                        }

                        NouvelleLigne = true;
                    }

                    mdl.eFermerSiDifferent(MdlBase);
                }

                foreach (DrawingDoc dessin in DicDessins.Values)
                {
                    int Errors = 0, Warnings = 0;
                    dessin.eModelDoc2().eActiver();
                    dessin.eFeuilleActive().eAjusterAutourDesVues();
                    dessin.eModelDoc2().ViewZoomtofit2();
                    dessin.eModelDoc2().Save3((int)swSaveAsOptions_e.swSaveAsOptions_SaveReferenced + (int)swSaveAsOptions_e.swSaveAsOptions_Silent, ref Errors, ref Warnings);
                }

                if (FermerPlan)
                {
                    foreach (ModelDoc2 dessin in DicDessins.Values)
                    {
                        dessin.eFermer();
                    }
                }

                if (DicErreur.Count > 0)
                {
                    WindowLog.SautDeLigne();

                    WindowLog.Ecrire("Liste des erreurs :");
                    foreach (var item in DicErreur)
                    {
                        WindowLog.Ecrire(" - " + item);
                    }

                    WindowLog.SautDeLigne();
                }
                else
                {
                    WindowLog.Ecrire("Pas d'erreur");
                }

                File.WriteAllText(Path.Combine(DossierDVP, "Log_CreerDvp.txt"), WindowLog.Resume);
            }
            catch (Exception e)
            {
                this.LogErreur(new Object[] { e });
            }
        }