How to read Hatch entity ?

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

Moderators: support, SDS, admin

Post Reply
pascal07

How to read Hatch entity ?

Post by pascal07 » 17 Mar 2015, 19:00

Hello

i want read entity CurvePolygon ( Hatch circle in joint image ) in a DXF File, for a conversion in my software dessin.
i must read each boundaries, vertex, line...or other entity ( if presents off course ).
i can not / Can you help me ?

Note : i want joint a image: BMP: not allowed !
JPG or PNG : Could not upload attachment to ./files/8725_3e4e85547ddfefc241dd38713166138f. ??
DXF : not alloweed ??
Bug or ??????????????????????

thanks / Pascal

my ( bad ) code :

vPoly: Tsg2DPolyline;
xP1,xP2: TF2DPoint;
sgCADCurvePolygon:TsgCADCurvePolygon;
vHatch: TsgCADCurvePolygon;
vBoundaryList: Tsg2DBoundaryList;
begin
if Sender is TsgCADCurvePolygon then
begin
sgCADCurvePolygon := Sender as TsgCADCurvePolygon;
i := sgCADCurvePolygon.Boundaries.Count;
O := sgCADCurvePolygon.Boundaries.Items[0];;
vBoundaryList := sgCADCurvePolygon.BoundaryData.Items[0];
i := vBoundaryList.Count;
for i := 0 to vBoundaryList.Count - 1 do
begin
vPoly := vBoundaryList.Items;
for j := 0 to vPoly.Count - 1 do
begin
xP1 := vPoly.StartPoint;
xP2 := vPoly.EndPoint;

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

Re: How to read Hatch entity ?

Post by support » 20 Mar 2015, 17:44

Hello Pascal,

Have a look at the code example below, it shows how to read a center point and radius for an elliptic boundary of the filled circle:

Code: Select all

procedure ReadHatchBoundaryParams(ACADImage: TsgCADImage; var ACenterPoint: TF2DPoint; var ARadius: TsgFloat);
var
  I, J, K: Integer;
  vCADCurvePolygon: TsgCADCurvePolygon;
  v2DCurve: Tsg2DCurve;
begin
  for I := 0 to ACADImage.Converter.Counts[csEntities] - 1 do
    if ACADImage.Converter.Entities[I].EntType = ceCurvePolygon then
    begin
      vCADCurvePolygon := ACADImage.Converter.Entities[I] as TsgCADCurvePolygon;
      for J := 0 to vCADCurvePolygon.BoundaryDataCount - 1 do
      for K := 0 to vCADCurvePolygon.BoundaryData[J].Count - 1 do
      begin
        v2DCurve := vCADCurvePolygon.BoundaryData[J].Items[K];
        if (v2DCurve.ClassName = 'Tsg2DArc') or (v2DCurve.ClassName = 'Tsg2DEllipse') then
        begin
          ACenterPoint := (v2DCurve as Tsg2DArc).CenterPoint;
          ARadius := (v2DCurve as Tsg2DArc).Radius;
        end;
      end;
    end;
end;

...

var
  vCenterPoint: TF2DPoint;
  vRadius: TsgFloat;
...

vCenterPoint := MakeF2DPoint(0,0);
vRadius := 0;
ReadHatchBoundaryParams(Img, vCenterPoint, vRadius);
Note: TsgCADCurvePolygon.BoundaryData is an array property starting from version 9.1.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Pascal07300
Posts: 5
Joined: 26 Jun 2015, 18:10

Re: How to read Hatch entity ?

Post by Pascal07300 » 10 Nov 2016, 13:21

Hello

i use now this code to import Hatch entity ( TsgCADCurvePolygon ) sine a year.
With a new DWF file ( note : i want joint it : DWG file : The extension dwg is not allowed. ??!! )
the result is not corect : Please joint image.

- How read this DWG file ?

- it s possible to convert a Ellipse to line segement ( with NumberOfPartsInSpline ) : it s possible to convert TsgCADCurvePolygon entity to lines segment ( same ) ?

thanks for your help / Pascal Eynard
Attachments
Forum_Import_DWG_file.PNG
Forum_Import_DWG_file.PNG (74.72 KiB) Viewed 28508 times

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

Re: How to read Hatch entity ?

Post by support » 10 Nov 2016, 19:16

Hello Pascal,

At first sight, your drawing algorithm doesn't seem to be quite correct. Please post the code of your drawing routine and send this DWG file to the Technical Support e-mail.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Pascal07300
Posts: 5
Joined: 26 Jun 2015, 18:10

Re: How to read Hatch entity ?

Post by Pascal07300 » 11 Nov 2016, 12:46

Hello, ok i m send this email, with my code and the DWG file
thanks for yours help
Pascal

Post Reply