Page 1 of 1
DWG to DXF conversion
Posted: 28 Mar 2006, 20:53
by Richard Wissler
I am looking for the easiest way to read a DWG file using CAD Import VCL and write its contents to DXF using DXF Export VCL. Do I have to iterate through the entities?
Rest regards
Richard
Posted: 29 Mar 2006, 14:57
by support
Dear Mr. Richard Wissler,
Here goes an example of import-export through metafile without iterating entities. This example is created basing on Demo Viewer from ..\CADImportVCL\Delphi\Demos\Viewer\.. folder (<b>CADImportVCL</b> is available on:
http://www.cadsofttools.com/download/cadimportvcl.zip).
<b>Note</b>: it is necessary to add to the project module <b>DXFExport</b> (<b>DXFExportVCL</b> is available on:
http://www.cadsofttools.com/download/dxfexportvcl.zip)
Code: Select all
<b>procedure</b> TForm1.SaveToDXF(AFileName: <b>string</b>);
<b>var</b>
E: TsgDXFExport;
vMet: TMetafile;
vGr: TGraphic;
vOffX, vOffY, vUSize: TsgFloat;
<b>begin</b>
vGr := sgPaintBox.Picture.Graphic;
E := TsgDXFExport.Create;
<b>try</b>
E.IsParseWhite := True;// False
<b>if not</b> ((vGr <b>is</b> TsgDXFImage) <b>or</b> (vGr <b>is</b> TMetafile)) <b>then
begin</b>
ShowMessage('Raster drawings can not be saved to DXF format');
Exit;
<b>end
else
begin
if not</b> (vGr <b>is</b> TsgDXFImage) <b>then
begin</b>
E.Use01MM := False;
E.Canvas.StretchDraw(Rect(0, 0, vGr.Width, vGr.Height), vGr);
E.EndDraw;
<b>end
else
begin</b>
vMet := TsgDXFImage(vGr).ExportToMetafile(vOffX, vOffY, vUSize);
DXFExport.OffsetX := vOffX;
DXFExport.OffsetY := vOffY;
E.UnitSize := vUSize;
E.LoadFromMetafile(vMet);
vMet.Free;
<b>end</b>;
<b>end</b>;
E.SaveToFile(AFileName);
<b>finally</b>
E.Free;
<b>end</b>;
<b>end</b>;
Current version of <b>DXFExportVCL</b> implements export to DXF through metafile only.
We plan to release direct export to DXF soon. The whole inner structure of CAD file will be saved.
Best regards,
Sergey Verbenko
please post questions to the forum or write to
support@cadsofttools.com
Posted: 29 Mar 2006, 16:37
by support
Hello all!!!
It is very important to note that when implementing the import-export through metafile the inner stucture of CAD file changes.
Finally the same picture is received when viewing source and destination files. But block and layers are lost and some copmplicated entites are converted to lines.
Sergey.
please post questions to the forum or write to
support@cadsofttools.com