Export DXF DWG
Moderators: SDS, support, admin
Export DXF DWG
Hello
I'm using CAD VCL 11.0 and I'm doing DXF and DWG export with TsgCADtoDXF and TsgCADtoDWG.
Most of the time the file can not be opened by Autocad.
I tried everything without success, thank you for your help.
I'm using CAD VCL 11.0 and I'm doing DXF and DWG export with TsgCADtoDXF and TsgCADtoDWG.
Most of the time the file can not be opened by Autocad.
I tried everything without success, thank you for your help.
Re: Export DXF DWG
Hello,
Do you create DXF and DWG files from scratch or resave the existing files? Please post your code, so that we could find what is going wrong.
Mikhail
Do you create DXF and DWG files from scratch or resave the existing files? Please post your code, so that we could find what is going wrong.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Export DXF DWG
Hello
I delete the file before rewriting it
Here is the code
I delete the file before rewriting it
Here is the code
Code: Select all
procedure TForm_FaceAvant.SaveToDXF;
var
AFileName : string;
vMC : TMetafileCanvas;
vM : TMetafile;
Nom_wmf : string;
vExport: TsgCADExport;
begin
Try
SaveDialogDXF.Filter := TXt_filtre_dwg+'|'+TXt_filtre_dxf+'|'+TXt_filtre_wmf;
if not SaveDialogDXF.Execute then Exit;
if (pos('.dxf', SaveDialogDXF.FileName) = 0) and (pos('.wmf', SaveDialogDXF.FileName) = 0) and (pos('.dwg', SaveDialogDXF.FileName) = 0)then
begin
case SaveDialogDXF.FilterIndex of
1: AFileName := SaveDialogDXF.FileName + '.dwg';
2: AFileName := SaveDialogDXF.FileName + '.dxf';
3: AFileName := SaveDialogDXF.FileName + '.wmf';
end;
end
else AFileName := SaveDialogDXF.FileName;
if FileExists(AFileName) then
begin
if Application.MessageBox(PChar(TXT_DXFDejaExistant), PChar(RSAttention), MB_OKCANCEL) = IDCANCEL then exit;
DeleteFile(AFileName);
end;
if pos('.dxf', AFileName) > 0 then
begin
vExport := TsgCADtoDXF.Create(TsgCADImage(sgPaintBox.Picture.Graphic)); //direct export
try
vExport.SaveToFile(AFileName);
Except
vExport.Free
end;
vExport.Free;
end else
if pos('.dwg', AFileName) > 0 then
begin
vExport := TsgCADtoDWG.Create(TsgCADImage(sgPaintBox.Picture.Graphic)); //direct export
try
vExport.SaveToFile(AFileName);
Except
vExport.Free
end;
vExport.Free
end else
begin
vM := TMetafile.Create;
try
vM.Width := FsgPaintBox.Width;
vM.Height := FsgPaintBox.Height;
vMC := TMetafileCanvas.Create(vM, 0);
try
vMC.StretchDraw(FsgPaintBox.ClientRect, FsgPaintBox.Picture.Graphic);
Except
vMC.Free;
end;
vMC.Free;
vM.SaveToFile(AFilename);
Except
vM.Free;
end;
vM.Free;
end;
Finally
End;
end;
Re: Export DXF DWG
Further information:
- The DWG export generates a bug each time.
- If there is TsgDXFDimension then the DXF export generates a bug each time.
- The DWG export generates a bug each time.
- If there is TsgDXFDimension then the DXF export generates a bug each time.
Re: Export DXF DWG
Hello,
Thank you for the information.
Your code for direct export to DWG/DXF formats uses improper class (TsgCADExport). You should use TsgCADDirectExport derivatives - TsgCADtoDWG and TsgCADtoDXF, depending on the output file extension (.dwg or .dxf).
Mikhail
Thank you for the information.
Your code for direct export to DWG/DXF formats uses improper class (TsgCADExport). You should use TsgCADDirectExport derivatives - TsgCADtoDWG and TsgCADtoDXF, depending on the output file extension (.dwg or .dxf).
Code: Select all
uses
..., SysUtils, CADImage, CADtoDWG, CADtoDXF;
...
implementation
{$R *.dfm}
...
procedure SaveToDWG(ACADImage: TsgCADImage; AFileName: string);
var
vCADtoDWG: TsgCADtoDWG;
begin
if not Assigned(ACADImage) then Exit;
vCADtoDWG := TsgCADtoDWG.Create(ACADImage);
try
vCADtoDWG.SaveToFile(AFileName);
finally
vCADtoDWG.Free;
end;
end;
procedure SaveToDXF(ACADImage: TsgCADImage; AFileName: string);
var
vCADtoDXF: TsgCADtoDXF;
begin
if not Assigned(ACADImage) then Exit;
vCADtoDXF := TsgCADtoDXF.Create(ACADImage);
try
vCADtoDXF.SaveToFile(AFileName);
finally
vCADtoDXF.Free;
end;
end;
procedure TForm_FaceAvant.SaveToCADByFileFormat(AFileName: string);
var
vFileExt: string;
begin
vFileExt := AnsiLowerCase(ExtractFileExt(AFileName));
if (vFileExt = '.dxf') then
SaveToDXF(TsgCADImage(sgPaintBox.Picture.Graphic), AFileName);
if (vFileExt = '.dwg') then
SaveToDWG(TsgCADImage(sgPaintBox.Picture.Graphic), AFileName);
end;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 54
- Joined: 14 Mar 2015, 22:33
Re: Export DXF DWG
This problem is coming form long time ago, I can see another user with the same problem.
I have tried both alternatives, loading an empty file and creating a new one in memory, in both cases the problem is the same.
I think what is needed is the publication of what entities is really capable of saving with CADExport?
Thaks!
I have tried both alternatives, loading an empty file and creating a new one in memory, in both cases the problem is the same.
I think what is needed is the publication of what entities is really capable of saving with CADExport?
Thaks!
Re: Export DXF DWG
Hello,
CADExport is the ancestor class of all export classes, you shouldn't use it for saving to DWG/DXF.
Mikhail
CADExport is the ancestor class of all export classes, you shouldn't use it for saving to DWG/DXF.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support