How to Export a DXF?

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
Eliseo
Posts: 7
Joined: 26 Nov 2008, 10:52

How to Export a DXF?

Post by Eliseo » 16 Jan 2009, 12:34

Hello

I don't know how to export the entities I have. I draw in a windows device context using Open GL instructions but I don't know how to export that to a DXF file. I tried this:

TWinControl *Wnd;

...... //Draw the entities in the DC of the window

TsgDXFExport *E = new TsgDXFExport();
try
{
Wnd->PaintTo(E->Canvas->Handle, 0, 0);
E->EndDraw();
E->SaveToFile(Filename);
}
__finally
{
delete E;
}

but it doesn't work.

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

Re: How to Export a DXF?

Post by support » 16 Jan 2009, 16:46

Hello!

We suppose the problem occurs because of a form in your example "knows" nothing about OpenGL actions. Your example is based on a code available in "DXF Export Demo" from DXF Export VCL package:

Code: Select all

procedure TfmDXFExporter.btnPaintToClick(Sender: TObject);
var
  E: TsgDXFExport;
begin
  if not SaveDialog.Execute then Exit;
  E := TsgDXFExport.Create;
...
  try
    PaintTo(E.Canvas.Handle, 0, 0);
    E. EndDraw;
    E.SaveToFile(SaveDialog.FileName);
  finally
    E.Free;
  end;
end;
where PaintTo is a member of TWinControl. This control contains respective drawing data and methods including info about DC. Your example contains the following line:

Code: Select all

Wnd->PaintTo(E->Canvas->Handle, 0, 0);
OpenGL draws on DC passing by respective TWinControl methods and control does not get necessary data for further transmitting to TsgDXFExport class object.

Thus this way is not accessable for communicating between OpenGL and DXF Export VCL.

We would suggest you to use direct export to DXF. This is a part of DXF Export VCL which requires CAD Import VCL. It allows creating DXF files fully compartible with AutoCAD. Demo "CADExportDemo" from DXF Export VCL (download link: http://www.cadsofttools.com/download/dxfexportvcl.zip) contains respective examples of creating entities.

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

Eliseo
Posts: 7
Joined: 26 Nov 2008, 10:52

Re: How to Export a DXF?

Post by Eliseo » 19 Jan 2009, 10:44

Thank you by your response.
I'm going to test your solution...

Eliseo
Posts: 7
Joined: 26 Nov 2008, 10:52

Re: How to Export a DXF?

Post by Eliseo » 03 Feb 2009, 12:02

Hi again

It seems that it works.
Now I have a new question. When I am exporting the layers there is a new layer created by default:

Source code:
if FCADImage.Converter.LayerByName('0') = nil then// always not nil

Why is that line included in your code? Is this necessary or can I avoid to export that created layer?

Thank you
Eliseo

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

Re: How to Export a DXF?

Post by support » 03 Feb 2009, 16:51

Hello!

This line may cause creating sometimes DXF file incompatible with AutoCAD. It is necessary to use latest version of DXF Export VCL. Please contact us via e-mail to sales@cadsofttools.com accordingly to this question.

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

Post Reply