Problem with exported hatch using DXFExport VCL

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

Moderators: SDS, support, admin

Post Reply
digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Problem with exported hatch using DXFExport VCL

Post by digitiger » 04 Jul 2006, 14:03

I am trying to create some hatch in a DXF exported from Delphi application using TDXFExport component.

Every thing works fine but when I specify the style for fill, then the hatch is not visible when same file is opened using AutoCAD. On checking the properties of these hatch, I noticed that the value for its pattern's SCALE and SPACING is set to "5.0267E+20".

While Exporting I have set the following properties
e.CurrentLayer := vLayer;
Data.Style := Byte(hsFDiagonal);
e.Offset := Onepercent * 20; //onepercent is variable holding value
e.AddHatch(Data);


Please advise

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

Post by support » 04 Jul 2006, 16:43

Hello,

Please try the following code:

Code: Select all

<b>procedure</b> TForm1.ForumN280Click(Sender: TObject);
<b>var</b>
  E: TsgDXFExport;
  Data: TdxfExportData;
  vLayer: TsgExpDXFLayer;
  Pt: PexpPoint;
  I: Integer;

  <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>
  E := TsgDXFExport.Create;
  <b>try</b>
    vLayer := TsgExpDXFLayer.Create('SimpleHatch');
    E.CurrentLayer := vLayer;
    FillChar(Data, SizeOf(Data), 0);
    Data.Color := ColorToDXF(TColor($68190));
    Data.Points := TList.Create;
    // Set boundary
    Data.Points.Add(TList.Create);
    New(Pt);
    Pt^ := MakeExpPoint(420, -30.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(430, -70.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(560, -80.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(580, -50.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(540, -20.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(420, -30.0, 0.0);
    TList(Data.Points[0]).Add(Pt);

    Data.Style := Byte(hsFDiagonal);

    Data.Scale.X := 1;
    Data.Rotation := 0.0;
    Data.Count := Data.Points.Count;
    E.Offset := 20;
    E.AddHatch(Data);

    // POLYLINE (based on the border of the previous HATCH)
    Data.Color := ColorToDXF(TColor($424F35));
    <b>for</b> I := 0 <b>to</b> Data.Points.Count - 1 <b>do</b>
      E.AddPolyLine(Data, I);

    FreeDataPoints;
    E.savetofile('D:\sampleHatch.dxf');
  <b>finally</b>
    Data.Points.Free;
    E.Free;
  <b>end</b>;
<b>end</b>;
<b>Note</b>:
<ul><li>you can change: E.Offset := 20;</li>
<li>you can set: Data.Style := Byte(hsFDiagonal);</li></ul>
See in sgConsts.pas:

Code: Select all

  TsgHatchStyle = (hsSolid, hsPatternData, hsHorizontal, hsVertical, hsFDiagonal,hsBDiagonal, hsCross, hsDiagCross);
Sergey.

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

digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Post by digitiger » 05 Jul 2006, 08:17

First of all thanks for that Sergey, the sample code given by you solves the problem. But there is one more issue involved with AddHatch method.

If in you sample code, the line in which Hatch is actually created is commented out as
//E.AddHatch(Data);

but boundary polyline is still created with same data points and saved to DXF file, and then on opening this DXF file in AutoCAD, the drawing is automatically zoomed to Extents but if the above mentioned line is not commented out and Hatch is also created in addition to polyline then the drawing is not getting zoomed to extents. InFact if the lower left corner of the drawing happens to be very far away from 0,0 then the drawing just appeas as a very small dot on top right corner because point 0,0 is also visible in the drawing, this sometimes confuses the user who is not able to notice the minute drawing in one corner.

I am not sure, if I am clear enough. So perhaps you may try out the following code (your sample code with changed data points) to understand the problem in better manner.

Code: Select all

<b>procedure</b> TForm1.ForumN280Click(Sender: TObject);
<b>var</b>
  E: TsgDXFExport;
  Data: TdxfExportData;
  vLayer: TsgExpDXFLayer;
  Pt: PexpPoint;
  I: Integer;

  <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>
  E := TsgDXFExport.Create;
  <b>try</b>
    vLayer := TsgExpDXFLayer.Create('SimpleHatch');
    E.CurrentLayer := vLayer;
    FillChar(Data, SizeOf(Data), 0);
    Data.Color := ColorToDXF(TColor($68190));
    Data.Points := TList.Create;
    // Set boundary
    Data.Points.Add(TList.Create);
    New(Pt);
    Pt^ := MakeExpPoint(100420, -30.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(100430, -70.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(100560, -80.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(100580, -50.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(100540, -20.0, 0.0);
    TList(Data.Points[0]).Add(Pt);
    New(Pt);
    Pt^ := MakeExpPoint(100420, -30.0, 0.0);
    TList(Data.Points[0]).Add(Pt);

    Data.Style := Byte(hsFDiagonal);

    Data.Scale.X := 1;
    Data.Rotation := 0.0;
    Data.Count := Data.Points.Count;
    E.Offset := 20;
    E.AddHatch(Data);

    // POLYLINE (based on the border of the previous HATCH)
    Data.Color := ColorToDXF(TColor($424F35));
    <b>for</b> I := 0 <b>to</b> Data.Points.Count - 1 <b>do</b>
      E.AddPolyLine(Data, I);

    FreeDataPoints;
    E.savetofile('D:\sampleHatch.dxf');
  <b>finally</b>
    Data.Points.Free;
    E.Free;
  <b>end</b>;
<b>end</b>;
IS IT A Bug?

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

Post by support » 05 Jul 2006, 20:00

We have fixed this bug.
Corrected DXFExportVCL is available on: http://www.cadsofttools.com/download/dxfexportvcl.zip

Thank you for your help.

Sergey.

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

digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Post by digitiger » 06 Jul 2006, 08:35

Thank you very much once again. I have downloaded the new library and updated my Delphi IDE. But now my project does not compiles and complains with following compiler error message:

"Unit DXFExport was compiled with a different version of sgConsts.SwapInts"

The sgConsts.dcu present in ...\DelphiExportVCL\Delphi\Lib7 is 22705 bytes and shows its time stamp of 05 July 06 4:34 PM.

Please Advise.

digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Post by digitiger » 06 Jul 2006, 09:05

Sorry for that Sergey. It was my fault as an old copy of same dcu file was in library path and was causing the problem. Now after fixing the path, it works find and the bug has vanished.

But it seems that the library file downloaded from "http://www.cadsofttools.com/download/dxfexportvcl.zip" is a demo version as it gives a message after completing the export call. Though we were using the purchased version of earlier release.

Please advise as from where can we download the licensed version of the update for commercial use.

Thanks

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

Post by support » 06 Jul 2006, 10:59

Please write us on support@cadsofttools.com and we'll give you a special link.

Sergey.

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

digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Post by digitiger » 07 Jul 2006, 10:51

We downloaded the full commercial version for which link was sent through mail, yesterday. But the old Delphi project which was running fine with the previous version of your library is now creating a buggy DXF output with the new version of DXFExport VCL. The problem is related to some wrong group ID somewhere.

The problem seems to be related to polyline and hatch.

Kindly investigate and advise.

Thanks

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

Post by support » 07 Jul 2006, 15:59

Hello,

Does your application works well with DXFExportVCL available on: http://www.cadsofttools.com/download/dxfexportvcl.zip ?

Sergey.

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

digitiger
Posts: 19
Joined: 29 May 2006, 10:01

Post by digitiger » 10 Jul 2006, 13:59

Thanks for your query, Sergey, I tried using the demo export vcl along with licensed version of CADImport (No source) VCL but the results are still same and give the same problem.

I am also forwarding three sets of emf and corresponding dxf files (both types created using DXFExport VCL components of demo version) for your testing, through email. Hope you will be able to pintpoint and troubleshoot the problem.

thanks

Post Reply