Problem with DXF Export of Polyline
Moderators: SDS, support, admin
Problem with DXF Export of Polyline
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
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>;
Hello John,
Please try the following code:
<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>
<b>DXFExport.pas</b>
As you can see <b>DXFExportVCL</b> supports double precision.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
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>;
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>;
Code: Select all
PexpPoint = ^TexpPoint;
TexpPoint = TFPoint;//TdxfPoint= for previous version
Sergey.
please post questions to the forum or write to support@cadsofttools.com