Problem with DXF Export of Polyline

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

Moderators: SDS, support, admin

Post Reply
JohnHutch
Posts: 4
Joined: 05 Nov 2006, 22:39
Location: Australia
Contact:

Problem with DXF Export of Polyline

Post by JohnHutch » 05 Nov 2006, 22:46

I have just bought and down loaded the latest version of DXF Export. I need to build a DXF file and need to export Polylines. The following code I copied from this forum (as the help example did not work) also does not work.

The dxf file produced does not contain correct coordinates, I expected the coordinates seen in the array to be in the dxf. I do not have the source so cannot debug further.

Pleas help.
John

Code: Select all

<b>procedure</b> 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 := <font color="blue">'ACADISO03W100'</font id="blue">;
    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>;

JohnHutch
Posts: 4
Joined: 05 Nov 2006, 22:39
Location: Australia
Contact:

Post by JohnHutch » 06 Nov 2006, 23:04

FURTHER
I believe although your doc says the TFPoint is a Double precision it is NOT.

If I substitute my own point record structure (JHPoint = record X,Y,Z:Double end) this works OK.

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

Post by support » 07 Nov 2006, 11:38

Hello John,

Please try the following code:

Code: Select all

<b>uses</b>
  ... DXFExport;

<b>type</b>
  TForm1 = <b>class</b>(TForm)
    ... 
    Button1: TButton;
    <b>procedure</b> Button1Click(Sender: TObject);
  <b>private</b>
    { Private declarations }
...

<b>procedure</b> TForm1.Button1Click(Sender: TObject);
<b>const</b> arrBezier: <b>array</b> [0..12] <b>of</b> TPoint = (
(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>
  E: TsgDXFExport;
  Pt: PexpPoint;
  D: TdxfExportData;  
  I: Integer;

  <b>procedure</b> FreeDataPoints;
  <b>var</b>
    J, K: Integer;
  <b>begin
    for</b> K := 0 <b>to</b> D.Points.Count - 1 <b>do
    begin
      for</b> J := 0 <b>to</b> TList(D.Points[K]).Count - 1 <b>do</b>
        Dispose(PexpPoint(TList(D.Points[K]).Items[J]));
      TList(D.Points[K]).Free;
    <b>end</b>;
    D.Points.Free;
  <b>end</b>;

<b>begin</b>
  E := TsgDXFExport.Create;
  E.AddLType(<font color="blue">'ACADISO03W100'</font id="blue">, [5,-5]);

  FillChar(D, SizeOf(D), 0);
  D.Color := DXF_PURPLE;
  D.Text := <font color="blue">'ACADISO03W100'</font id="blue">;
  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>;

    E.AddPolyLine(D,0);    
    E.SaveToFile(<font color="blue">'c:\polyline.dxf'</font id="blue">);
  <b>finally</b>
    FreeDataPoints;
    E.Free;
  <b>end</b>;
<b>end</b>;
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"> FURTHER
I believe although your doc says the TFPoint is a Double precision it is NOT.

If I substitute my own point record structure (JHPoint = record X,Y,Z:Double end) this works OK.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
The following lines are from the sources:

<b>sgConsts.pas</b>

Code: Select all

<b>type</b>
  TsgFloat = Double;

PFPoint = ^TFPoint;
  TFPoint = <b>record
  case</b> Integer <b>of</b>
    0: (X, Y, Z: TsgFloat);
    1: (V: <b>array</b>[0..2] <b>of</b> TsgFloat);
  <b>end</b>;
<b>DXFExport.pas</b>

Code: Select all

  PexpPoint = ^TexpPoint;
  TexpPoint = TFPoint;//TdxfPoint= for previous version 
As you can see <b>DXFExportVCL</b> supports double precision.

Sergey.

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

Post Reply