Exporting in DXF format

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Venkat
Posts: 7
Joined: 01 Apr 2012, 12:01

Exporting in DXF format

Post by Venkat » 05 Apr 2012, 14:25

Hi All,
I am trying to export as dxf file using CADImport.dll. I followed below code.

String inFilePath;
inFilePath = @"C:\Users\Administrator\Desktop\Source\Image Files\Sample.tif";
string OutFilePath;
OutFilePath = @"C:\Users\Administrator\Desktop\Source\Drawing Files\Sample.dxf";
cadimg = CADImage.CreateImageByExtension(inFilePath);
cadimg.LoadFromFile(inFilePath);
CADImport.Export.DirectCADtoDXF.CADtoDXF cadexp= new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadimg);
cadexp.SaveToFile(OutFilePath);

But I didn't get content of inputfile. Can any one suggest how to solve this issue? Thanks in advance

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Exporting in DXF format

Post by support » 05 Apr 2012, 15:15

Hello.
Tif is the raster format. A raster image can be added to DXF file as Image entity. CAD Import .NET provides CADImageEnt class that represents AutoCAD Image entity. DirectCADtoDXF class doesn't allow export raster files to DXF. This task can be completed by creating new CADImage object, adding a CADImageEnt object and export to DXF:

Code: Select all

        if (this.cadImage == null)
        {
            this.cadImage = new CADImage();
            this.cadImage.InitialNewImage();
        }

        CADImageEnt entRaster = new CADImageEnt();

        string tmp = @"d:\1.jpg";
        Bitmap bmpTmp;
        if (!System.IO.File.Exists(tmp)) return;
        try
        {
            bmpTmp = new Bitmap(tmp);
        }
        catch
        {
            return;
        }
        CADImageDef def = new CADImageDef();
        def.FileName = tmp;
        def.Loaded(this.cadImage.Converter);
        entRaster.ImageDef = def;
        entRaster.Color = CADConst.clNone;
        entRaster.Size = new DPoint(bmpTmp.Width, bmpTmp.Height, 0);
        entRaster.Loaded(this.cadImage.Converter);

        this.cadImage.Converter.ImageDefs.Add(entRaster.ImageDef);
        this.cadImage.Converter.OnCreate(entRaster);
        this.cadImage.CurrentLayout.AddEntity(entRaster);

        this.cadImage.GetExtents();

        CADtoDXF vExp = new CADtoDXF(cadImage);
        vExp.SaveToFile(@"d:\AddRaster.dxf");
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Venkat
Posts: 7
Joined: 01 Apr 2012, 12:01

Re: Exporting in DXF format

Post by Venkat » 06 Apr 2012, 06:32

Hi, Thanks for quick reply.
I tried your sample, but still I am not getting content of file. Here I ma trying in my sample web application. Here is my code

String inFilePath;
inFilePath = @"C:\Users\Administrator\Desktop\Image Files\Sample..tif";
string OutFilePath;
OutFilePath = @"C:\Users\Administrator\Desktop\Drawing Files\Sample.dxf";
CADImage cadimg = null;
if (cadimg == null)
{
cadimg = new CADImage();
cadimg.InitialNewImage();
}
CADImageEnt entRaster = new CADImageEnt();
CADImageDef Def = new CADImageDef();
Bitmap bmp;
if (System.IO.File.Exists(inFilePath))
{
bmp = new Bitmap(inFilePath);
Def.FileName = inFilePath;
Def.Loaded(cadimg.Converter);
entRaster.ImageDef = Def;
entRaster.Color = CADConst.clNone;
entRaster.Size = new DPoint(bmp.Width, bmp.Height, 0);
entRaster.Loaded(cadimg.Converter);
cadimg.Converter.ImageDefs.Add(entRaster.ImageDef);
cadimg.Converter.OnCreate(entRaster);
cadimg.CurrentLayout.AddEntity(entRaster);
cadimg.GetExtents();
CADtoDXF DXFExport = new CADtoDXF(cadimg);
DXFExport.SaveToFile(OutFilePath);
}
else
{
return;
}

Can any one please guide me. Thanks in advance.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Exporting in DXF format

Post by support » 06 Apr 2012, 11:24

Hello.
Please specify what did you mean by:
...still I am not getting content of file...
DXF file created? Is it contain source image?

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Venkat
Posts: 7
Joined: 01 Apr 2012, 12:01

Re: Exporting in DXF format

Post by Venkat » 06 Apr 2012, 12:08

Hi,
DXF file was created. But it is not containing any source image.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Exporting in DXF format

Post by support » 06 Apr 2012, 14:51

Hello.
The created file contains Image entity. It can be imported and displayed with CAD Import .NET. Unfortunately import/visualization in AutoCAD is incorrect. We will develop a solution for this problem.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Venkat
Posts: 7
Joined: 01 Apr 2012, 12:01

Re: Exporting in DXF format

Post by Venkat » 11 Apr 2012, 09:07

Hi thanks for your response.
We are interested to take license version of CADImportnet.Net . So Can U tell me when will we expect solution for above problem. How much time will take approximately. So that we can take decision.

Our requirement is
1) Convert .tif (Any raster image) to .dxf
2) Convert .dxf to .jpg ( to view in browser)
3) Have to export in dxf, pdf, dwg etc.....
Can we achieve all above requirements using CADImport.Net. Can you clarify that please.
Looking for quick response. Thanks

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Exporting in DXF format

Post by support » 11 Apr 2012, 10:51

Hello.
We plan to provide a solution within one-two weeks.
CAD Import .NET allows export raster images to DXF by adding Image entity to a drawing then export. DXF drawings can be exported to raster images that can be used with ASP.NET (viewing in browsers). The library provides export to DXF, PDF, HPGL/2, CGM vector formats. However export to DWG not allowed. Please inform us if the provided functionality is satisfactory for your task.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Exporting in DXF format

Post by support » 19 Apr 2012, 17:07

Hello.
We have found the cause of problem, image entity is exported with wrong flags. The problem is fixed. The solution will be available within next release version. You can set the flags value manually with current version to receive correct DXF drawing:

Code: Select all

        //...
        entRaster.ImageDef = def;
        entRaster.Color = CADConst.clNone;
        entRaster.Size = new DPoint(bmpTmp.Width, bmpTmp.Height, 0);
// add this:
        entRaster.Flags = 3;
        entRaster.Loaded(this.cadImage.Converter);
        //...
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply