GENERATING .DWG FILE BY A C# CODE

GENERATING .DWG FILE BY A C# CODE

Anonymous
Not applicable
698 Views
1 Reply
Message 1 of 2

GENERATING .DWG FILE BY A C# CODE

Anonymous
Not applicable

Hi,

 

I'm editing a image, loading it in a pictureBox. When i've done the changes i want to save the image as a .dwg file, but when i want to open the file AUTOCAD doesnt recognise so i'm not able to open the file on AUTOCAD. Is there any way which i can obtain a correct .dwg file, from a edited image in c#?

 

This is the code that i'm using to obtain the .dwg file, it works for jpg file, but not for .dwg file

 

private void Generar_Click(object sender, EventArgs e)
        {
            SaveFileDialog Guardar = new SaveFileDialog();
            Guardar.Filter = "DWG(*.dwg)|*DWG|DXG(*.DXG)|*.DXG|JPEG(*.JPG)|*.JPG|BMP(*.BMP)|*.BMP";
            Bitmap bmp = new Bitmap(pictureBox.Image);
            Graphics gr = Graphics.FromImage(bmp);
            Pen p = new Pen(Color.Red);
            p.Width = 5.0f;
            gr.DrawRectangle(p, 1, 2, 30, 40);
            pictureBox.Image = bmp;
            Image Imagen = pictureBox.Image;
            Guardar.ShowDialog();
            Imagen.Save(Guardar.FileName);

        }

 

Thanks

 

 

 

 

0 Likes
699 Views
1 Reply
Reply (1)
Message 2 of 2

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

a PictureBox holds a raster image, a DWG file holds vector objects so you can't just save the content of a raster to make it vectors ... you also can't save the content of a PictureBox to create a DOC or XLS file.

 

Plus: DWG is a propriatary format used by AutoCAD, to create such files you need AutoCAD and the geometry in the AutoCAD's database object.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes