How to Export a DXF?
Moderators: SDS, support, admin
How to Export a DXF?
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.
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?
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:
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:
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.
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;
Code: Select all
Wnd->PaintTo(E->Canvas->Handle, 0, 0);
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
Chat support on Skype: cadsofttools.support
Re: How to Export a DXF?
Thank you by your response.
I'm going to test your solution...
I'm going to test your solution...
Re: How to Export a DXF?
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
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?
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.
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
Chat support on Skype: cadsofttools.support