Cant create a hatch as first entity , BUG?
Posted: 14 Jun 2006, 18:42
I have been trying to create several entities in loop while exporting a vector drawing to DXF. The entities depend on actual contents of the onscreen drawing in a Delphi application.
Sometimes the first entity required to be created in DXF file (and sometime the only entity required) is a HATCH. In this case the exported file seems to be corrupt and while trying to open it in AutoCAD I get the following error message:
"The following error was encountered while reading
in HATCH starting at line 340:
Error: expected group code 91
Invalid or incomplete DXF input -- drawing discarded."
The simplimfied Delphi code being used for above is as below:
Please review the above code and tell me if I am doing something wrong or what.
Also sometime I encounter a delphi error message for invalid pointer operation while freeing the points (it can be seen through above code also. Maybe I am doing something in wrong manner. Please help.
thanking you in anticipation
SK Arora
Sometimes the first entity required to be created in DXF file (and sometime the only entity required) is a HATCH. In this case the exported file seems to be corrupt and while trying to open it in AutoCAD I get the following error message:
"The following error was encountered while reading
in HATCH starting at line 340:
Error: expected group code 91
Invalid or incomplete DXF input -- drawing discarded."
The simplimfied Delphi code being used for above is as below:
Code: Select all
<b>procedure</b> TForm1.FormCreate(Sender: TObject);
<b>var</b>
e: TsgDXFExport;
<b>begin</b>
e := TsgDXFExport.create;
<b>try</b>
DrawSubbasins(e);
<b>finally</b>
e.free ;
<b>end</b>;
<b>end</b>;
<b>procedure</b> TForm1.DrawSubbasins(E:TsgDXFExport);
<b>var</b>
Data: TdxfExportData;
vLayer: TsgExpDXFLayer;
Pt: PDXFPoint;
<b>procedure</b> FreeDataPoints;
<b>var</b>
J, K: Integer;
<b>begin
for</b> K := 0 <b>to</b> Data.Points.Count - 1 <b>do
begin
for</b> J := 0 <b>to</b> TList(Data.Points[K]).Count - 1 <b>do</b>
Dispose(TList(Data.Points[K]).Items[J]);
TList(Data.Points[K]).Free;
<b>end</b>;
<b>end</b>;
<b>begin</b>
vLayer := TsgExpDXFLayer.Create('StormNET Subbasins Fill');
e.CurrentLayer := vLayer;
Data.Color := ColorToDXF(clteal);
Data.Count := 4;
Data.Points := TList.Create;
Data.Points.Add(TList.Create);
<b>try</b>
New(Pt);
Pt^.X := 1000;
Pt^.Y := 1000;
Pt^.Z := 0;
TList(Data.Points[0]).Add(Pt);
Pt^.X := 1100;
Pt^.Y := 1000;
Pt^.Z := 0;
TList(Data.Points[0]).Add(Pt);
Pt^.X := 1100;
Pt^.Y := 2000;
Pt^.Z := 0;
TList(Data.Points[0]).Add(Pt);
Pt^.X := 1500;
Pt^.Y := 1500;
Pt^.Z := 0;
TList(Data.Points[0]).Add(Pt);
e.CurrentLayer := vLayer;
e.AddHatch(Data);
e.savetofile('C:\sampleHatch.dxf');
<b>finally</b>
FreeDataPoints;
Data.Points.Free;
<b>end</b>;
<b>end</b>;
Also sometime I encounter a delphi error message for invalid pointer operation while freeing the points (it can be seen through above code also. Maybe I am doing something in wrong manner. Please help.
thanking you in anticipation
SK Arora