Пример #1
0
        private DrawingDoc CreerPlan(String materiau, Double epaisseur, Boolean mettreAJourExistant)
        {
            String Fichier = NomFichierPlan(materiau, epaisseur);

            if (DicDessins.ContainsKey(Fichier))
            {
                return(DicDessins[Fichier]);
            }

            DrawingDoc Dessin = null;
            ModelDoc2  Mdl    = null;

            if (mettreAJourExistant)
            {
                Mdl = Sw.eOuvrir(Path.Combine(DossierDVP, Fichier), eTypeDoc.Dessin);
            }

            if (Mdl.IsNull())
            {
                Dessin = Sw.eCreerDocument(DossierDVP, Fichier, eTypeDoc.Dessin, CONSTANTES.MODELE_DE_DESSIN_LASER).eDrawingDoc();
            }
            else
            {
                Dessin = Mdl.eDrawingDoc();
                return(Dessin);
            }

            Dessin.eFeuilleActive().SetName(Fichier);
            DicDessins.Add(Fichier, Dessin);

            Dessin.eModelDoc2().pAppliquerOptionsDessinLaser(AfficherNotePliage, TailleInscription);

            return(Dessin);
        }
Пример #2
0
        private DrawingDoc CreerPlan(String materiau, Double epaisseur)
        {
            String Fichier = String.Format("{0}{1} - Ep{2}",
                                           String.IsNullOrWhiteSpace(RefFichier) ? "" : RefFichier + " - ",
                                           materiau.eGetSafeFilename("-"),
                                           epaisseur.ToString().Replace('.', ',')
                                           ).Trim();

            if (DicDessins.ContainsKey(Fichier))
            {
                return(DicDessins[Fichier]);
            }

            if (MajPlans)
            {
                var di            = new DirectoryInfo(DossierDVP);
                var NomFichierExt = Fichier + eTypeDoc.Dessin.GetEnumInfo <ExtFichier>();
                var r             = di.GetFiles(NomFichierExt, SearchOption.TopDirectoryOnly);
                if (r.Length > 0)
                {
                    int        Erreur = 0, Warning = 0;
                    DrawingDoc dessin = App.Sw.OpenDoc6(Path.Combine(DossierDVP, NomFichierExt),
                                                        (int)swDocumentTypes_e.swDocDRAWING,
                                                        (int)swOpenDocOptions_e.swOpenDocOptions_Silent,
                                                        "",
                                                        ref Erreur,
                                                        ref Warning).eDrawingDoc();
                    DicDessins.Add(Fichier, dessin);

                    return(dessin);
                }
            }

            DrawingDoc Dessin = Sw.eCreerDocument(DossierDVP, Fichier, eTypeDoc.Dessin, CONSTANTES.MODELE_DE_DESSIN_LASER).eDrawingDoc();

            Dessin.eFeuilleActive().SetName(Fichier);
            DicDessins.Add(Fichier, Dessin);

            ModelDoc2 mdl = Dessin.eModelDoc2();

            LayerMgr LM = mdl.GetLayerManager();

            LM.AddLayer("GRAVURE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER);
            LM.AddLayer("QUANTITE", "", 1227327, (int)swLineStyles_e.swLineCONTINUOUS, (int)swLineWeights_e.swLW_LAYER);

            ModelDocExtension ext = mdl.Extension;

            ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swFlatPatternOpt_ShowFixedFace, 0, false);
            ext.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swShowSheetMetalBendNotes, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, AfficherNotePliage);

            TextFormat tf = ext.GetUserPreferenceTextFormat(((int)(swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat)), 0);

            tf.CharHeight = TailleInscription / 1000.0;
            ext.SetUserPreferenceTextFormat((int)swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat, 0, tf);

            return(Dessin);
        }
Пример #3
0
        private static Parameter eAttributDernierDossier(this DrawingDoc dessin)
        {
            if (AttDef.IsNull())
            {
                AttDef = App.Sw.DefineAttribute(ATTRIBUT_NOM);
                AttDef.AddParameter(ATTRIBUT_PARAM, (int)swParamType_e.swParamTypeString, 0, 0);
                AttDef.Register();
            }

            // Recherche de l'attribut dans la piece
            SolidWorks.Interop.sldworks.Attribute Att = null;
            ModelDoc2 mdl = dessin.eModelDoc2();
            Parameter P   = null;
            Feature   F   = mdl.eChercherFonction(f => { return(f.Name == ATTRIBUT_NOM); });

            if (F.IsRef())
            {
                Att = F.GetSpecificFeature2();

                P = (Parameter)Att.GetParameter(ATTRIBUT_PARAM);

                if (P.IsNull())
                {
                    Att.Delete(false);
                    Att = null;
                }
            }

            if (Att.IsNull())
            {
                Att = AttDef.CreateInstance5(mdl, null, ATTRIBUT_NOM, 1, (int)swInConfigurationOpts_e.swAllConfiguration);
                P   = (Parameter)Att.GetParameter(ATTRIBUT_PARAM);
            }

            return(P);
        }
Пример #4
0
        private GeomVue AppliquerOptionsVue(DrawingDoc dessin, PartDoc piece, View vue)
        {
            vue.ShowSheetMetalBendNotes = AfficherNotePliage;

            MathUtility SwMath = App.Sw.GetMathUtility();

            var liste = piece.eListeFonctionsDepliee();

            if (liste.Count == 0)
            {
                return(null);
            }

            Feature FonctionDepliee = liste[0];

            GeomVue g     = null;
            var     Liste = FonctionDepliee.eListeSousFonction();

            Feature f = Liste[0];

            // Les fonctions "Lignes de pliage" et "Cube de visualisation" ne sont pas toujours correctement
            // nommées donc ont considère que la première fonction = Ligne de pliage et la deuxième = Cube de visualisation

            if (f.GetTypeName2() == FeatureType.swTnProfileFeature)
            {
                ModelDoc2 mdlBase = dessin.eModelDoc2();

                f.eSelectionnerById2Dessin(mdlBase, vue);

                if (AfficherLignePliage)
                {
                    mdlBase.UnblankSketch();
                }
                else
                {
                    mdlBase.BlankSketch();
                }

                mdlBase.eEffacerSelection();
            }

            f = Liste[1];

            if (f.GetTypeName2() == FeatureType.swTnProfileFeature)
            {
                try
                {
                    f.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressFeature);

                    Sketch Esquisse = f.GetSpecificFeature2();

                    if (OrienterDvp)
                    {
                        Double Angle = AngleCubeDeVisualisation(vue, Esquisse);

                        // On oriente la vue
                        switch (OrientationDvp)
                        {
                        case eOrientation.Portrait:
                            if (Math.Abs(Angle) != MathX.eRad90D)
                            {
                                Double a = MathX.eRad90D - Math.Abs(Angle);
                                vue.Angle = (Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a;
                            }
                            break;

                        case eOrientation.Paysage:
                            if (Math.Abs(Angle) != 0 || Math.Abs(Angle) != MathX.eRad180D)
                            {
                                Double a = MathX.eRad90D - Math.Abs(Angle);
                                vue.Angle = ((Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a) - MathX.eRad90D;
                            }
                            break;

                        default:
                            break;
                        }
                    }

                    g = new GeomVue(vue, Esquisse);
                }
                catch
                {
                    WindowLog.EcrireF("Impossible d'orienter la vue : {0}", vue.Name);
                }
            }



            //FonctionDepliee.eParcourirSousFonction(
            //    f =>
            //    {
            //        if (f.Name.StartsWith(CONSTANTES.LIGNES_DE_PLIAGE))
            //        {
            //            //String NomSelection = f.Name + "@" + vue.RootDrawingComponent.Name + "@" + vue.Name;
            //            //Dessin.Extension.SelectByID2(NomSelection, "SKETCH", 0, 0, 0, false, 0, null, 0);

            //            ModelDoc2 mdlBase = dessin.eModelDoc2();

            //            f.eSelectionnerById2Dessin(mdlBase, vue);

            //            if (AfficherLignePliage)
            //                mdlBase.UnblankSketch();
            //            else
            //                mdlBase.BlankSketch();

            //            mdlBase.eEffacerSelection();
            //        }
            //        else if (f.Name.StartsWith(CONSTANTES.CUBE_DE_VISUALISATION))
            //        {
            //            try
            //            {
            //                f.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressFeature);

            //                Sketch Esquisse = f.GetSpecificFeature2();

            //                if (OrienterDvp)
            //                {
            //                    Double Angle = AngleCubeDeVisualisation(vue, Esquisse);

            //                    // On oriente la vue
            //                    switch (OrientationDvp)
            //                    {
            //                        case eOrientation.Portrait:
            //                            if (Math.Abs(Angle) != MathX.eRad90D)
            //                            {
            //                                Double a = MathX.eRad90D - Math.Abs(Angle);
            //                                vue.Angle = (Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a;
            //                            }
            //                            break;
            //                        case eOrientation.Paysage:
            //                            if (Math.Abs(Angle) != 0 || Math.Abs(Angle) != MathX.eRad180D)
            //                            {
            //                                Double a = MathX.eRad90D - Math.Abs(Angle);
            //                                vue.Angle = ((Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a) - MathX.eRad90D;
            //                            }
            //                            break;
            //                        default:
            //                            break;
            //                    }
            //                }

            //                g = new GeomVue(vue, Esquisse);
            //            }
            //            catch
            //            {
            //                WindowLog.EcrireF("Impossible d'orienter la vue : {0}", vue.Name);
            //            }
            //            return true;
            //        }
            //        return false;
            //    }
            //    );

            return(g);
        }
Пример #5
0
        public View CreerVueToleDvp(DrawingDoc dessin, Sheet feuille, PartDoc piece, String configDepliee, String Ref, String materiau, int quantite, Double epaisseur)
        {
            var NomVue = piece.eModelDoc2().eNomSansExt() + " - " + configDepliee;

            dessin.eModelDoc2().eEffacerSelection();

            View Vue = dessin.CreateFlatPatternViewFromModelView3(piece.eModelDoc2().GetPathName(), configDepliee, 0, 0, 0, !AfficherLignePliage, false);

            Vue.ScaleDecimal = 1;

            if (Vue.IsRef())
            {
                Vue.SetName2(NomVue);

                GeomVue g = AppliquerOptionsVue(dessin, piece, Vue);

                Vue.eSelectionner(dessin);

                try
                {
                    Note Note = dessin.eModelDoc2().InsertNote(String.Format("qté {0} // réf {1} [{2}] (Ep{3})", quantite, Ref, materiau, epaisseur));
                    Note.SetTextJustification((int)swTextJustification_e.swTextJustificationCenter);

                    Annotation Annotation = Note.GetAnnotation();

                    TextFormat swTextFormat = Annotation.GetTextFormat(0);
                    // Hauteur du texte en fonction des dimensions du dvp, 2.5% de la dimension max du dvp
                    swTextFormat.CharHeight = Math.Max(0.005, Math.Floor(Math.Max(g.Ht, g.Lg) * 0.025 * 1000) * 0.001);
                    Annotation.SetTextFormat(0, false, swTextFormat);

                    Annotation.Layer = "QUANTITE";
                    Annotation.SetLeader3((int)swLeaderStyle_e.swNO_LEADER, (int)swLeaderSide_e.swLS_SMART, true, true, false, false);
                    // Décalage du texte en fonction des dimensions du dvp, 0.1% de la dimension max du dvp
                    Annotation.SetPosition(g.ptCentreRectangleX, g.ptMinY - Math.Max(0.005, Math.Floor(Math.Max(g.Ht, g.Lg) * 0.001 * 1000) * 0.001), 0);
                    g.Agrandir(Note);
                }
                catch (Exception e)
                {
                    WindowLog.Ecrire("  - Erreur");
                    this.LogMethode(new Object[] { e });
                }

                if (InscrireNomTole)
                {
                    try
                    {
                        Note Note = dessin.eModelDoc2().InsertNote(Ref);
                        Note.SetTextJustification((int)swTextJustification_e.swTextJustificationCenter);

                        Annotation Annotation = Note.GetAnnotation();

                        TextFormat swTextFormat = Annotation.GetTextFormat(0);
                        // Hauteur du texte en fonction des dimensions du dvp, 2.5% de la dimension max du dvp
                        swTextFormat.CharHeight = TailleInscription * 0.001;
                        Annotation.SetTextFormat(0, false, swTextFormat);

                        Annotation.Layer = "GRAVURE";
                        Annotation.SetLeader3((int)swLeaderStyle_e.swNO_LEADER, (int)swLeaderSide_e.swLS_SMART, true, true, false, false);
                    }
                    catch (Exception e)
                    {
                        WindowLog.Ecrire("  - Erreur");
                        this.LogMethode(new Object[] { e });
                    }
                }

                PositionnerVue(feuille, Vue, g);

                return(Vue);
            }

            WindowLog.Ecrire("  - Erreur : pas de vue dvp");

            return(null);
        }
Пример #6
0
        private void CreerVue(Corps corps)
        {
            if (!corps.Dvp || !corps.Maj)
            {
                return;
            }

            var    QuantiteDiff = Quantite * (corps.Qte + corps.QteSup);
            Double Epaisseur    = corps.Dimension.eToDouble();

            var cheminFichier = corps.CheminFichierRepere;

            if (!File.Exists(cheminFichier))
            {
                return;
            }

            var mdlCorps = Sw.eOuvrir(cheminFichier);

            if (mdlCorps.IsNull())
            {
                return;
            }

            var piece = mdlCorps.ePartDoc();

            var listeCfgPliee  = mdlCorps.eListeNomConfiguration(eTypeConfig.Pliee);
            var NomConfigPliee = listeCfgPliee[0];

            if (mdlCorps.eNomConfigActive() != NomConfigPliee)
            {
                mdlCorps.ShowConfiguration2(NomConfigPliee);
            }

            WindowLog.EcrireF("{0}  x{1}", corps.RepereComplet, QuantiteDiff);
            piece.ePremierCorps(false).eVisible(true);

            Double Volume1 = piece.ePremierCorps().eVolume();

            piece.ePremierCorps(false).eVisible(true);

            corps.NbPli = piece.pNbPli();
            var listeCfgDepliee = mdlCorps.eListeNomConfiguration(eTypeConfig.Depliee);

            if (listeCfgDepliee.Count == 0)
            {
                return;
            }

            var NomConfigDepliee = listeCfgDepliee[0];

            if (!mdlCorps.ShowConfiguration2(NomConfigDepliee))
            {
                WindowLog.EcrireF("  - Pas de configuration dvp");
                return;
            }

            corps.CalculerDiffPliage(Volume1, piece.ePremierCorps().eVolume());

            mdlCorps.ePartDoc().ePremierCorps(false).eVisible(true);
            mdlCorps.EditRebuild3();
            mdlCorps.ePartDoc().ePremierCorps(false).eVisible(true);

            DrawingDoc dessin = CreerPlan(corps.Materiau, Epaisseur, MettreAjourCampagne);

            dessin.eModelDoc2().eActiver();
            Sheet Feuille = dessin.eFeuilleActive();

            try
            {
                if (MettreAjourCampagne)
                {
                    foreach (var vue in Feuille.eListeDesVues())
                    {
                        var mdlVue = vue.ReferencedDocument;
                        if (mdlCorps.GetPathName() == mdlVue.GetPathName())
                        {
                            vue.eSelectionner(dessin);
                            dessin.eModelDoc2().EditDelete();
                            dessin.eModelDoc2().eEffacerSelection();
                            break;
                        }
                    }
                }

                View v = CreerVueToleDvp(dessin, Feuille, piece, NomConfigDepliee, corps.RepereComplet, corps.Materiau, QuantiteDiff, Epaisseur);
            }
            catch (Exception e)
            {
                WindowLog.Ecrire("  - Erreur");
                this.LogMethode(new Object[] { e });
            }
            finally
            {
                WindowLog.Ecrire("  - Ok");
            }

            mdlCorps.ShowConfiguration2(NomConfigPliee);

            mdlCorps.eFermer();
        }
Пример #7
0
        private GeomVue AppliquerOptionsVue(DrawingDoc dessin, PartDoc piece, View vue)
        {
            vue.ShowSheetMetalBendNotes = AfficherNotePliage;

            MathUtility SwMath = App.Sw.GetMathUtility();

            ModelDoc2 mdl = dessin.eModelDoc2();

            Body2 c = piece.eChercherCorps(CONSTANTES.NOM_CORPS_DEPLIEE, true);

            GeomVue g = null;

            c.eFonctionEtatDepliee().eParcourirSousFonction(
                f =>
            {
                if (f.Name.StartsWith(CONSTANTES.LIGNES_DE_PLIAGE))
                {
                    String NomSelection = f.Name + "@" + vue.RootDrawingComponent.Name + "@" + vue.Name;
                    mdl.Extension.SelectByID2(NomSelection, "SKETCH", 0, 0, 0, false, 0, null, 0);
                    if (AfficherLignePliage)
                    {
                        mdl.UnblankSketch();
                    }
                    else
                    {
                        mdl.BlankSketch();
                    }

                    mdl.eEffacerSelection();
                }
                else if (f.Name.StartsWith(CONSTANTES.CUBE_DE_VISUALISATION))
                {
                    try
                    {
                        f.eModifierEtat(swFeatureSuppressionAction_e.swUnSuppressFeature);

                        Sketch Esquisse = f.GetSpecificFeature2();

                        if (OrienterDvp)
                        {
                            Double Angle = AngleCubeDeVisualisation(vue, Esquisse);

                            // On oriente la vue
                            switch (OrientationDvp)
                            {
                            case eOrientation.Portrait:
                                if (Math.Abs(Angle) != MathX.eRad90D)
                                {
                                    Double a  = MathX.eRad90D - Math.Abs(Angle);
                                    vue.Angle = (Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a;
                                }
                                break;

                            case eOrientation.Paysage:
                                if (Math.Abs(Angle) != 0 || Math.Abs(Angle) != MathX.eRad180D)
                                {
                                    Double a  = MathX.eRad90D - Math.Abs(Angle);
                                    vue.Angle = ((Math.Sign(Angle) == 0 ? 1 : Math.Sign(Angle)) * a) - MathX.eRad90D;
                                }
                                break;

                            default:
                                break;
                            }
                        }

                        g = new GeomVue(vue, Esquisse);
                    }
                    catch
                    {
                        WindowLog.EcrireF("Impossible d'orienter la vue : {0}", vue.Name);
                    }
                    return(true);
                }
                return(false);
            }
                );

            return(g);
        }
Пример #8
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 });
            }
        }
Пример #9
0
        public View CreerVueToleDvp(DrawingDoc dessin, Sheet feuille, PartDoc piece, String configDepliee, String Ref, String materiau, int quantite, Double epaisseur)
        {
            // Si des corps autre que la tole dépliée sont encore visible dans la config, on les cache et on recontruit tout
            foreach (Body2 pCorps in piece.eListeCorps(false))
            {
                if ((pCorps.Name == CONSTANTES.NOM_CORPS_DEPLIEE))
                {
                    pCorps.eVisible(true);
                }
                else
                {
                    pCorps.eVisible(false);
                }
            }

            var NomVue = piece.eModelDoc2().eNomSansExt() + " - " + configDepliee;

            if (MajPlans)
            {
                foreach (var vue in feuille.eListeDesVues())
                {
                    if (vue.GetName2() == NomVue)
                    {
                        vue.eSelectionner(dessin);
                        dessin.eModelDoc2().Extension.DeleteSelection2((int)swDeleteSelectionOptions_e.swDelete_Advanced);
                        break;
                    }
                }
            }

            dessin.eModelDoc2().eEffacerSelection();

            View Vue = dessin.CreateFlatPatternViewFromModelView3(piece.eModelDoc2().GetPathName(), configDepliee, 0, 0, 0, !AfficherLignePliage, false);

            Vue.ScaleDecimal = 1;

            if (Vue.IsRef())
            {
                Vue.SetName2(NomVue);

                GeomVue g = AppliquerOptionsVue(dessin, piece, Vue);

                Vue.eSelectionner(dessin);

                {
                    Note Note = dessin.eModelDoc2().InsertNote(String.Format("{0}× {1} [{2}] (Ep{3})", quantite, Ref, materiau, epaisseur));
                    Note.SetTextJustification((int)swTextJustification_e.swTextJustificationCenter);

                    Annotation Annotation = Note.GetAnnotation();

                    TextFormat swTextFormat = Annotation.GetTextFormat(0);
                    // Hauteur du texte en fonction des dimensions du dvp, 2.5% de la dimension max du dvp
                    swTextFormat.CharHeight = Math.Max(0.005, Math.Floor(Math.Max(g.Ht, g.Lg) * 0.025 * 1000) * 0.001);
                    Annotation.SetTextFormat(0, false, swTextFormat);

                    Annotation.Layer = "QUANTITE";
                    Annotation.SetLeader3((int)swLeaderStyle_e.swNO_LEADER, (int)swLeaderSide_e.swLS_SMART, true, true, false, false);
                    // Décalage du texte en fonction des dimensions du dvp, 0.1% de la dimension max du dvp
                    Annotation.SetPosition(g.ptCentreRectangleX, g.ptMinY - Math.Max(0.005, Math.Floor(Math.Max(g.Ht, g.Lg) * 0.001 * 1000) * 0.001), 0);
                    g.Agrandir(Note);
                }

                if (InscrireNomTole)
                {
                    Note Note = dessin.eModelDoc2().InsertNote(Ref);
                    Note.SetTextJustification((int)swTextJustification_e.swTextJustificationCenter);

                    Annotation Annotation = Note.GetAnnotation();

                    TextFormat swTextFormat = Annotation.GetTextFormat(0);
                    // Hauteur du texte en fonction des dimensions du dvp, 2.5% de la dimension max du dvp
                    swTextFormat.CharHeight = TailleInscription * 0.001;
                    Annotation.SetTextFormat(0, false, swTextFormat);

                    Annotation.Layer = "GRAVURE";
                    Annotation.SetLeader3((int)swLeaderStyle_e.swNO_LEADER, (int)swLeaderSide_e.swLS_SMART, true, true, false, false);
                }

                if (ConvertirEsquisse)
                {
                    String titre = Vue.GetName2();
                    Vue.ReplaceViewWithSketch();
                    Vue = feuille.eListeDesVues().Last();
                    Vue.SetName2(titre);
                    g = new GeomVue(Vue);
                }

                PositionnerVue(feuille, Vue, g);

                return(Vue);
            }

            return(null);
        }
Пример #10
0
        private void AppliquerOptionsVue(ModelDoc2 mdlBase, DrawingDoc dessin, View vue)
        {
            try
            {
                var liste = vue.ReferencedDocument.ePartDoc().eListeFonctionsDepliee();
                if (liste.Count > 0)
                {
                    liste[0].eParcourirSousFonction(f => AppliquerOptionsPliage(mdlBase, f, vue));
                }

                Boolean GravureExistante = false;
                if (vue.GetAnnotationCount() > 0)
                {
                    foreach (Annotation ann in vue.GetAnnotations())
                    {
                        if (ann.Layer == CONSTANTES.CALQUE_GRAVURE)
                        {
                            GravureExistante = true;
                            break;
                        }
                    }
                }

                if (!GravureExistante && InscrireNomTole && (vue.GetVisibleComponentCount() > 0))
                {
                    // Selection de la première face
                    var        ListeComps = (object[])vue.GetVisibleComponents();
                    var        ListeFaces = (object[])vue.GetVisibleEntities2((Component2)ListeComps[0], (int)swViewEntityType_e.swViewEntityType_Face);
                    var        Face       = (Entity)ListeFaces[0];
                    SelectData selData    = default(SelectData);
                    selData      = mdlBase.SelectionManager.CreateSelectData();
                    selData.View = vue;
                    Face.Select4(false, selData);

                    // On insère la note
                    Note Note = dessin.eModelDoc2().InsertNote(String.Format("$PRPWLD:\"{0}\"", CONSTANTES.REF_DOSSIER));
                    // On récupère le repère
                    var repere = Note.GetText();
                    // On l'insère en dur
                    Note.PropertyLinkedText = repere;

                    Note.SetTextJustification((int)swTextJustification_e.swTextJustificationCenter);

                    Annotation Annotation = Note.GetAnnotation();

                    TextFormat swTextFormat = Annotation.GetTextFormat(0);
                    swTextFormat.CharHeight = TailleInscription * 0.001;
                    Annotation.SetTextFormat(0, false, swTextFormat);

                    Annotation.Layer = "GRAVURE";
                    Annotation.SetLeader3((int)swLeaderStyle_e.swNO_LEADER, (int)swLeaderSide_e.swLS_SMART, true, true, false, false);

                    // On modifie la position du texte
                    Double[] P = (Double[])vue.Position;
                    Annotation.SetPosition2(P[0], P[1], 0);
                }
            }
            catch (Exception e)
            {
                this.LogErreur(new Object[] { e });
            }
        }