How to use TsgDXFAttdef and TsgDXFAttrib with TDXFExport

If you have any comments or questions about our developing tools, please do not hesitate to contact us at this forum

Moderators: admin, SDS, support

How to use TsgDXFAttdef and TsgDXFAttrib with TDXFExport

Postby Alexander » 17 May 2012, 11:40

Hi All,

I found some good examples on how to use these 2 entities with TsgDXFInsert and the TsgCADImage class (demos\CADExportDemo project). Do you have some examples on how to use these entities by means of TsgDXFExport ?

Thanks,
Alexander
Alexander
 
Posts: 6
Joined: 17 May 2012, 11:16

Re: How to use TsgDXFAttdef and TsgDXFAttrib with TDXFExport

Postby support » 18 May 2012, 07:55

Hello.
TsgDXFExport doesn't provide methods to export attributes and attribute definitions. This class is outdated. We recommend using TsgCADImage and TsgCADtoDXF classes as shown in CADExportDemo project.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2228
Joined: 30 Mar 2005, 08:36
Location: Russia

Re: How to use TsgDXFAttdef and TsgDXFAttrib with TDXFExport

Postby Alexander » 20 May 2012, 18:04

Hi,

According to your suggestions, I have migrated the existing code to use the TsgCADImage and TsgCADtoDXF classes. All tests I made failed: exception throw on SaveToFile. The same happen when modifing the CADExportDemo project.
Here the code:

var
vDXFExport: TsgCADtoDXF;
begin
try
if FCADFile <> nil then
FCADFile.Free;
FCADFile := TsgCADImage.Create;
FCADFile.Converter.InitializeSections;
//add or not DXF entities to CADFile
........
vDXFExport := TsgCADtoDXF.Create(FCADFile);
vDXFExport.SaveToFile(fileName); //exception thown !!
finally
FCADFile := nil;
vDXFExport.Free;
vDXFExport := nil;
end;

After a while I found out that adding the line FCADFile.GetExtents magic happens: no exception !
So the modified the code looks like this:

.......
//add or not DXF entities to CADFile
//export to DXF file
FCADFile.GetExtents;// ??
vDXFExport := TsgCADtoDXF.Create(FCADFile);
vDXFExport.SaveToFile(datName);
finally
.......

Is it a bug or a feature ?

Thanks in advance,
Alexander


PS. It would be advisable to mark the TsgDXFExport class as deprecated, either the documentation nor the examples give a hint about this state of the class.
Alexander
 
Posts: 6
Joined: 17 May 2012, 11:16

Re: How to use TsgDXFAttdef and TsgDXFAttrib with TDXFExport

Postby support » 21 May 2012, 09:17

Hello Alexander.
GetExtents method calculates extents for all layouts and sets the model as current layout. The current layout must be specified before export. You can set CurrentLayout instead GetExtents call:
Code: Select all
var
  line: TsgDXFLine;
  Image: TsgCADImage;
  vExp: TsgCADtoDXF;
begin
  Image := TsgCADImage.Create;
  Image.Converter.InitializeSections();
  Image.CurrentLayout := Image.Layouts[0];
 
  line := TsgDXFLine.Create();
  line.Point := MakeFPoint(80, 100, 0);
  line.Point1 := MakeFPoint(180, 200, 0);
  line.Color := clBlue;

  Image.Converter.Loads(line);
  Image.Converter.OnCreate(line);
  Image.CurrentLayout.AddEntity(line);

  vExp := TsgCADtoDXF.Create(Image);
  vExp.SaveToFile('d:\1.dxf');

The documentation describes TsgDXFExport class is obsolete, please check Welcome, What's New, demo topics.

Alexander.
Please post questions to the forum or write to support@cadsofttools.com
support
 
Posts: 2228
Joined: 30 Mar 2005, 08:36
Location: Russia


Return to CADImportVCL + DXFExportVCL

Who is online

Users browsing this forum: No registered users and 2 guests

cron