Page 1 of 1
How to Export a DXF?
Posted: 16 Jan 2009, 12:34
by Eliseo
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.
Re: How to Export a DXF?
Posted: 16 Jan 2009, 16:46
by support
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.
Re: How to Export a DXF?
Posted: 19 Jan 2009, 10:44
by Eliseo
Thank you by your response.
I'm going to test your solution...
Re: How to Export a DXF?
Posted: 03 Feb 2009, 12:02
by Eliseo
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
Re: How to Export a DXF?
Posted: 03 Feb 2009, 16:51
by support
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.