Exemplo n.º 1
0
        public static void Draw_Repere(ActivCAD.ActivCAD.IActivCAD app)
        {
            string  res;
            double  max_pm = Get_Max_Pm();
            section sect;

            //On calcule le nombre de ligne verticales
            double vertical_nbr = Math.Ceiling(max_pm);

            double max_pm_adapte = max_pm * UNITE_X;

            Get_Section_Infos();

            //Console.WriteLine("Get sections OK " + Section_Infos.Count);

            //On dessine les lignes horizontales
            foreach (object obj in Section_Infos.Values)
            {
                sect = (section)obj;

                //Console.WriteLine(sect.Y);
                //Console.WriteLine(sect.intitule);
                //Console.WriteLine(sect.heure);
                //Console.WriteLine(sect.type);

                if (sect.type != string.Empty)
                {
                    //object[] horizontal_params = { 0, sect.Y * UNITE_Y, 0, max_pm_adapte, sect.Y * UNITE_Y, 0, 252, 252, 252, "legende", "Continuous", Properties.Settings.Default.LignePath };
                    //res = app.GetType().InvokeMember("AjouteLigne", BindingFlags.InvokeMethod, null, app, horizontal_params);
                    //Console.WriteLine(sect.type);
                    if (sect.type == "generatrice_primaire")
                    {
                        res = app.AjouteLigne(0, sect.Y * UNITE_Y, 0, max_pm_adapte, sect.Y * UNITE_Y, 0, 51, 51, 51, "legende", "Continuous", Properties.Settings.Default.LignePath);
                    }
                    else if (sect.type == "generatrice_secondaire")
                    {
                        res = app.AjouteLigne(0, sect.Y * UNITE_Y, 0, max_pm_adapte, sect.Y * UNITE_Y, 0, 51, 51, 51, "legende", "ACAD_ISO07W100", Properties.Settings.Default.LignePath);
                    }
                    else if (sect.type == "ligne_milieu")
                    {
                        res = app.AjouteLigne(0, sect.Y * UNITE_Y, 0, max_pm_adapte, sect.Y * UNITE_Y, 0, 51, 51, 51, "legende", "CENTER2", Properties.Settings.Default.LignePath);
                    }
                    else
                    {
                        res = app.AjouteLigne(0, sect.Y * UNITE_Y, 0, max_pm_adapte, sect.Y * UNITE_Y, 0, 51, 51, 51, "legende", "Continuous", Properties.Settings.Default.LignePath);
                    }
                }

                //Legende de l axe vertical
                string legende = string.Empty;
                if (sect.intitule != string.Empty)
                {
                    legende = sect.intitule + " - " + sect.heure;
                }
                else
                {
                    legende = sect.heure;
                }

                //object[] legende_params = { -120, sect.Y * UNITE_Y, 0, legende, 7 };
                //res = app.GetType().InvokeMember("AjouteLegende", BindingFlags.InvokeMethod, null, app, legende_params);
                res = app.AjouteLegende(-120, sect.Y * UNITE_Y, 0, legende, 7);
            }


            sect = (section)Section_Infos["YMAX"];
            double vertical_line_YMAX = (sect.Y * UNITE_Y) + 10;

            //On dessine les lignes verticales
            double x = 0;

            for (int i = 0; i <= vertical_nbr; i++)
            {
                x = i * UNITE_X;
                if (i % 5 == 0)
                {
                    //object[] vertical_params = { x, 0, 0, x, vertical_line_YMAX, 0, 252, 252, 252, "legende", "Continuous", Properties.Settings.Default.LignePath };
                    //res = app.GetType().InvokeMember("AjouteLigne", BindingFlags.InvokeMethod, null, app, vertical_params);
                    res = app.AjouteLigne(x, 0, 0, x, vertical_line_YMAX, 0, 51, 51, 51, "legende", "Continuous", Properties.Settings.Default.LignePath);
                    //object[] legende_params = { x, vertical_line_YMAX + 20, 0, i + " m", 7 };
                    //res = app.GetType().InvokeMember("AjouteLegende", BindingFlags.InvokeMethod, null, app, legende_params);
                    res = app.AjouteLegende(x, vertical_line_YMAX + 20, 0, i + " m", 7);
                }
                else
                {
                    //object[] vertical_params = { x, vertical_line_YMAX - 10, 0, x, vertical_line_YMAX, 0, 252, 252, 252, "legende", "Continuous", Properties.Settings.Default.LignePath };
                    //res = app.GetType().InvokeMember("AjouteLigne", BindingFlags.InvokeMethod, null, app, vertical_params);
                    res = app.AjouteLigne(x, vertical_line_YMAX - 10, 0, x, vertical_line_YMAX, 0, 51, 51, 51, "legende", "Continuous", Properties.Settings.Default.LignePath);
                }
            }
        }
Exemplo n.º 2
0
        public static void Draw_Observations(ActivCAD.ActivCAD.IActivCAD app)
        {
            double x1 = 0;
            double x2 = 0;

            double y1 = 50;
            double y2 = 50;

            double epaisseur = 1;
            double echelle   = 1;
            double angle     = 0;

            //section sect;

            string res;

            //On parcourt les observations
            foreach (dessin des in destab)
            {
                x1 = double.Parse(des.pm1) * UNITE_X;
                y1 = Get_Y1(des.h1);

                byte R = byte.Parse(des.couleur.Split(Char.Parse("|"))[0]);
                byte G = byte.Parse(des.couleur.Split(Char.Parse("|"))[1]);
                byte B = byte.Parse(des.couleur.Split(Char.Parse("|"))[2]);

                if (des.type == "lineaires")
                {
                    if (des.pm2 == string.Empty & des.h2 == string.Empty)
                    {
                        return;
                    }

                    if (des.pm2 != string.Empty)
                    {
                        x2 = double.Parse(des.pm2) * UNITE_X;
                        y2 = Get_Y2(des.h2, y1, x1, x2);

                        if (des.epaisseur != null | des.epaisseur != string.Empty)
                        {
                            epaisseur = double.Parse(des.epaisseur);
                        }

                        //app.AddNewLineType(des.ligne, Properties.Settings.Default.LignePath);

                        //On récupère le point d'intersection de l'object et de l'axe Y=0
                        double new_x2 = Get_Cut_X(des.h1, des.h2, x1, y1, x2, y2);
                        if (new_x2 >= 0)
                        {
                            res = app.AjoutePolyline(x1, y1, new_x2, 0, epaisseur, R, G, B, "legende", des.ligne, Properties.Settings.Default.LignePath);
                            res = app.AjoutePolyline(new_x2, 24 * UNITE_Y, x2, y2, epaisseur, R, G, B, "legende", des.ligne, Properties.Settings.Default.LignePath);
                        }
                        else
                        {
                            res = app.AjoutePolyline(x1, y1, x2, y2, epaisseur, R, G, B, "legende", des.ligne, Properties.Settings.Default.LignePath);
                        }
                    }
                    else
                    {
                        x2  = x1;
                        y2  = Get_Y2(des.h2, y1, x1, x2);
                        res = app.AjoutePolyline(x1, y1, x2, y2, epaisseur, R, G, B, "legende", des.ligne, Properties.Settings.Default.LignePath);
                    }
                }
                else if (des.type == "surfaciques")
                {
                    //Surfacique
                    if (des.pm2 != string.Empty)
                    {
                        x2 = double.Parse(des.pm2) * UNITE_X;
                        y2 = Get_Y2(des.h2, y1, x1, x2);

                        if (des.angle != null | des.angle != string.Empty)
                        {
                            angle = double.Parse(des.angle);
                        }

                        if (des.echelle != null | des.echelle != string.Empty)
                        {
                            echelle = double.Parse(des.echelle);
                        }

                        //Console.WriteLine(des.hachure);
                        //Console.WriteLine("surf angle : " + des.angle);
                        //Console.WriteLine("surf echelle : " + des.echelle);

                        //On verifie si l'objet est coupé ou pas
                        if (Is_Cut(des.h1, des.h2) == true)
                        {
                            //object[] observation_params_1 = { x1, y1, x2, 0, 35, 0.6, R, G, B, "legende", "NET3", Properties.Settings.Default.HachurePath };
                            //res = app.GetType().InvokeMember("AjouteSurface", BindingFlags.InvokeMethod, null, app, observation_params_1);

                            res = app.AjouteSurface(x1, y1, x2, 0, angle, echelle, R, G, B, "legende", des.hachure, Properties.Settings.Default.HachurePath);

                            //object[] observation_params_2 = { x1, 24 * UNITE_Y, x2, y2, 35, 0.6, R, G, B, "legende", "NET3", Properties.Settings.Default.HachurePath };
                            //res = app.GetType().InvokeMember("AjouteSurface", BindingFlags.InvokeMethod, null, app, observation_params_2);

                            res = app.AjouteSurface(x1, 24 * UNITE_Y, x2, y2, angle, echelle, R, G, B, "legende", des.hachure, Properties.Settings.Default.HachurePath);
                        }
                        else
                        {
                            //object[] observation_params = { x2, y2, x1, y1, 35, 0.6, R, G, B, "legende", "NET3", Properties.Settings.Default.HachurePath };
                            //res = app.GetType().InvokeMember("AjouteSurface", BindingFlags.InvokeMethod, null, app, observation_params);

                            res = app.AjouteSurface(x2, y2, x1, y1, angle, echelle, R, G, B, "legende", des.hachure, Properties.Settings.Default.HachurePath);
                        }
                    }
                }
                else if (des.type == "ponctuels")
                {
                    if (des.echelle != null | des.echelle != string.Empty)
                    {
                        echelle = double.Parse(des.echelle);
                    }

                    //Console.WriteLine("symbole : " + des.symbole);
                    //Console.WriteLine("ponc echelle : " + des.echelle);
                    //object[] observation_params = {x1, y1, 0, R, G, B, 0.8, "legende", "bloc2", Properties.Settings.Default.SymbolePath + "bloc.dwg" };
                    //app.GetType().InvokeMember("AjoutePonctuel", BindingFlags.InvokeMethod, null, app, observation_params);

                    app.AjoutePonctuel(x1, y1, 0, R, G, B, echelle, "legende", des.symbole, Properties.Settings.Default.SymbolePath + des.symbole + ".dwg");
                }
            }
        }
Exemplo n.º 3
0
        public static void Launch_Autocad()
        {
            //object res;

            // "AutoCAD.Application.17" uses 2007 or 2008,
            //  whichever was most recently run

            // "AutoCAD.Application.17.1" uses 2008, specifically
            // "AutoCAD.Application.16.2" uses 2006
            // "AutoCAD.Application.18" uses 2010

            const string progID = "AutoCAD.Application.18";

            AcadApplication acApp = null;

            try
            {
                acApp = (AcadApplication)Marshal.GetActiveObject(progID);
            }
            catch
            {
                try
                {
                    Type acType = Type.GetTypeFromProgID(progID);
                    acApp = (AcadApplication)Activator.CreateInstance(acType, true);
                }
                catch
                {
                    MessageBox.Show("Cannot create object of type \"" + progID + "\"");
                }
            }
            if (acApp != null)
            {
                try
                {
                    // By the time this is reached AutoCAD is fully
                    // functional and can be interacted with through code
                    acApp.Visible = true;

                    ActivCAD.ActivCAD.IActivCAD app = (ActivCAD.ActivCAD.IActivCAD)acApp.GetInterfaceObject("ActivCAD.Commands");

                    if (app != null)
                    {
                        //---------------------------------------- On dessine le repère --------------------------------------------------
                        //----------------------------------------------------------------------------------------------------------------
                        Draw_Repere(app);
                        //----------------------------------------------------------------------------------------------------------------
                        //----------------------------------------------------------------------------------------------------------------
                        //New_Calc();
                        //---------------------------------------- On dessine les observations -------------------------------------------
                        //----------------------------------------------------------------------------------------------------------------
                        Draw_Observations(app);
                        //----------------------------------------------------------------------------------------------------------------
                        //----------------------------------------------------------------------------------------------------------------


                        // Let's generate the arguments to pass in:
                        // an integer and a double

                        //x1 / y1 / x2 / y2 / epaisseur / R / G / B / linetype / linefile
                        //Observations
                        //object[] args_poly1 = { 12, 34, 22, 43, 2, 255, 255, 0, "legende", "Continuous", Properties.Settings.Default.LignePath };
                        //object[] args_poly2 = { 37, 19, 42, 50, 1, 55, 255, 0, "legende", "Continuous", Properties.Settings.Default.LignePath };
                        //object[] args_poly3 = { 136, 70, 166, 52, 1, 55, 205, 0, "legende", "Continuous", Properties.Settings.Default.LignePath };

                        //Hachures
                        //object[] args_surf1 = { 69, 78, 47, 65, 120, 0.6, 252, 125, 252, "legende", "NET3", Properties.Settings.Default.HachurePath };

                        // Now let's call our method dynamically
                        //object res = app.GetType().InvokeMember("Init_Autocad_Environment", BindingFlags.InvokeMethod, null, app, null);
                        //res = app.GetType().InvokeMember("AjoutePolyline", BindingFlags.InvokeMethod, null, app, args_poly1);
                        //res = app.GetType().InvokeMember("AjoutePolyline", BindingFlags.InvokeMethod, null, app, args_poly2);
                        //res = app.GetType().InvokeMember("AjoutePolyline", BindingFlags.InvokeMethod, null, app, args_poly3);

                        //res = app.GetType().InvokeMember("AjouteSurface", BindingFlags.InvokeMethod, null, app, args_surf1);

                        //app.GetType().InvokeMember("MyPoly", BindingFlags.InvokeMethod, null, app, null);

                        acApp.ZoomExtents();
                        //MessageBox.Show("AddNumbers returned: " + res.ToString());
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Problem executing component: " + ex.Message);
                }
            }
        }