DXFExport Access Violation

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
schulz
Posts: 16
Joined: 03 Apr 2006, 18:02
Location: Germany

DXFExport Access Violation

Post by schulz » 24 May 2006, 16:04

Hallo Sergey,
my test application runs in a access violation when saving file when i
use AddPolyLine or AddPolyBezier. I'm using D6

with best regards
Armin

Code: Select all

<b>procedure</b> TForm1.Test(E: TsgDXFExport);
<b>const</b> arrBezier: <b>array</b> [0..12] <b>of</b> TdxfPoint = (
       (X:200;Y:230), (X:190;Y:310), (X:280;Y:330), (X:310;Y:310), (X:340;Y:290),
       (X:390;Y:270), (X:355;Y:225), (X:330;Y:240), (X:305;Y:255), (X:415;Y:255),
       (X:440;Y:240),  (X:480;Y:220), (X:430;Y:200));
<b>var</b>
  Pt: PDXFPoint;
  D: TdxfExportData;
  I: Integer;
<b>begin</b>
  D.Points := TList.Create;
  D.Points.Add(TList.Create);
  <b>try</b>
    D.Count := High(arrBezier)-Low(arrBezier)+1;
    <b>for</b> I := 0 <b>to</b> D.Count - 1 <b>do
    begin</b>
      New(Pt);
      Pt^.X := arrBezier[I].X;
      Pt^.Y := arrBezier[I].Y;
      Pt^.Z := 0;
      TList(D.Points[0]).Add(Pt);
    <b>end</b>;
    D.Text := 'ACADISO03W100';
    // E.AddPolyBezier(D, 0);
    E.AddPolyLine(D, 0);
  <b>finally</b>
    D.Points.Free;
    E.Free;
  <b>end</b>;
<b>end</b>;

<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>var</b>
  E: TsgDXFExport;
  D: TdxfExportData;
  vLayer : TsgExpDXFLayer;
<b>begin
  try</b>
    E := TsgDXFExport.Create;
    E.AddLType('ACADISO03W100', [5]);
    E.BeginBlock('Test');
    Test(E);
    E.EndBlock;
    FillChar(D, SizeOf(D), 0);
    vLayer := TsgExpDXFLayer.Create('Blocks');
    E.CurrentLayer := vLayer;
    D.Text := 'Test';
    D.Point := MakedxfPoint(0, 0, 0);
    D.Scale.X := 3;
    D.Scale.Y := 3;
    E.Insert(D);
    E.SaveToFile('c:\tmp\Test.dxf');
  <b>finally</b>
    E.Free;
  <b>end</b>;
<b>end</b>;

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 24 May 2006, 18:42

Hallo Armin,

The following line:

Code: Select all

  E.Free;
is superfluous in procedure

Code: Select all

 TForm1.Test(E: TsgDXFExport);

We made some corrections to your code:

Code: Select all

<b>procedure</b> TForm1.Test(E: TsgDXFExport);
<b>const</b> arrBezier: <b>array</b> [0..12] <b>of</b> TdxfPoint = (
(X:200;Y:230), (X:190;Y:310), (X:280;Y:330), (X:310;Y:310), (X:340;Y:290),
(X:390;Y:270), (X:355;Y:225), (X:330;Y:240), (X:305;Y:255), (X:415;Y:255),
(X:440;Y:240), (X:480;Y:220), (X:430;Y:200));
<b>var</b>
  Pt: PDXFPoint;
  D: TdxfExportData;
  I: Integer;
<b>begin</b>
  D.Points := TList.Create;
  <b>try</b>
    D.Points.Add(TList.Create);
    D.Count := High(arrBezier)-Low(arrBezier)+1;
    <b>for</b> I := 0 <b>to</b> D.Count - 1 <b>do
    begin</b>
      New(Pt);
      Pt^.X := arrBezier[I].X;
      Pt^.Y := arrBezier[I].Y;
      Pt^.Z := 0;
      TList(D.Points[0]).Add(Pt);
    <b>end</b>;
    D.Text := 'ACADISO03W100';
    E.AddPolyLine(D, 0);
  <b>finally
    for</b> I := 1 <b>to</b> TList(D.Points[0]).Count - 1 <b>do</b>
      Dispose(TList(D.Points[0])[I]);
    TList(D.Points[0]).Free;
    D.Points.Free;
  <b>end</b>;
<b>end</b>;

Sergey.

please post questions to the forum or write to support@cadsofttools.com

schulz
Posts: 16
Joined: 03 Apr 2006, 18:02
Location: Germany

Post by schulz » 24 May 2006, 19:12

Hallo Sergey,
sorry that' a cut and copy mistake. I try to extract the code again on Monday. I've some free day's.

Best regards Armin

Post Reply