Page 1 of 1

How to read Hatch entity ?

Posted: 17 Mar 2015, 19:00
by pascal07
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;

Re: How to read Hatch entity ?

Posted: 20 Mar 2015, 17:44
by support
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

Re: How to read Hatch entity ?

Posted: 10 Nov 2016, 13:21
by Pascal07300
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

Re: How to read Hatch entity ?

Posted: 10 Nov 2016, 19:16
by support
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

Re: How to read Hatch entity ?

Posted: 11 Nov 2016, 12:46
by Pascal07300
Hello, ok i m send this email, with my code and the DWG file
thanks for yours help
Pascal