3d Polyline points mismatch

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

Moderators: SDS, support, admin

Post Reply
AlexBV
Posts: 10
Joined: 08 May 2020, 23:33

3d Polyline points mismatch

Post by AlexBV » 30 Jun 2020, 02:05

Hello,

I am extracting real coordinates from elements, and I have a lot of mismatch number of coordinates with 3d polylines:

Let me explain with a little code:

vDrawing is defined as: TsgDWGImage

Actual code:
NDWGElm := vDrawing.Converter.Sections[csEntities].Count; //sections
tDWGP := TsgDXFPoint.Create; //Create Entities Once
tDWGL := TsgDXFLine.Create;
Vtex := TsgDXFVertex.Create;
tSOL := TsgDXFSolid.Create;
tTRA := tsgDXFTrace.Create;
tDWGC := TsgDXFCircle.Create;
tDWGA := TsgDXFArc.Create;
tELI := TsgDXFEllipse.Create;
tDWGPL := TsgDXFPolyLine.Create;
tDWGLW := TsgDXFLWPolyLine.Create;
for I := 0 to NDWGElm-1 do Begin
tEnt := vDrawing.Converter.Entities ; //tEnt is tsgDXFEntity

Case tEnt.EntType of //Explore entities
ceEntity : Memo1.Lines.Add('ceEntity'); //HEre no problem
cePoint : Memo1.Lines.Add('cePoint');
ceLine : Memo1.Lines.Add('ceLine');
ceSolid : Memo1.Lines.Add('ceSolid');
ceTrace : Memo1.Lines.Add('ceTrace');
ceCircle : Memo1.Lines.Add('cCircle');
ceArc : Memo1.Lines.Add('ceARC');
ceEllipse : Memo1.Lines.Add('ceEllipse'); //Here no problem

cePolyline : Begin //here with polyline
tDWGPL.AssignEntity (tEnt);
Color := tDWGPL.Color;
LWidth := tDWGPL.LineWeight);
LStyle := tDWGPL.LineType.Name;
Layer := tDWGPL.Layer.Name;

NPts := tDWGPL.Count; //Here the NPts gives double number of points if they are even number of points
// or double minus one if they are odd number of points

For j := 0 to NPts - 1 do Begin //Data is an array of mypoints
Data[j+1].XY.X := tDWGPL.Vertexes [j].Point.X;
Data[j+1].XY.Y := tDWGPL.Vertexes [j].Point.Y;
Data[j+1].Z := tDWGPL.Vertexes [j].Point.Z; // I also get weird flags in tDWGL.Vertextes[j].Flags
End; // I get flag 40, 48 ..not documented
if tDWGPL.Closed then Begin
Inc(NPTS);
Data[NPTS] := Data[1];
End;
End;
ceLWPolyline : Begin //extracting LWPolyline I do not have any problem...
tDWGLW.AssignEntity(tEnt);
Color := tDWGLW.Color;
LWidth := tDWGLW.LineWeight*1000;
LStyle := tDWGLW.LineType.Name;
Layer := tDWGLW.Layer.Name;

NPts := tDWGLW.Count; // Here NPTS is correct

For j := 0 to NPts - 1 do Begin
Data[j+1].XY.X := tDWGLW.Vertexes [j].Point.X;
Data[j+1].XY.Y := tDWGLW.Vertexes [j].Point.Y;
Data[j+1].Z := tDWGLW.Elevation;
End;
if tDWGLW.Closed then Begin
Inc(NPTS);
Data[NPTS] := Data[1];
End;
End;
End;

Thanks for your input
Alex

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

Re: 3d Polyline points mismatch

Post by support » 01 Jul 2020, 03:55

Hello Alex,

Could you please attach a drawing file which shows the problem?

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

AlexBV
Posts: 10
Joined: 08 May 2020, 23:33

Re: 3d Polyline points mismatch

Post by AlexBV » 01 Jul 2020, 07:37

Here is a file with lots of vertex with flags 40 and 48

Thanks.. !!
Attachments
649650.zip
(495.65 KiB) Downloaded 636 times

AlexBV
Posts: 10
Joined: 08 May 2020, 23:33

Re: 3d Polyline points mismatch

Post by AlexBV » 04 Jul 2020, 03:03

I have also another issue with respect to LWPolylines.

The coordinates I get from this file are not at all the real coordinates. (If I extract the same way as shown)
I get negative coordinates and wrong elevation ..

Thanks for your interest !!
Attachments
lwpl.zip
(27.18 KiB) Downloaded 602 times

AlexBV
Posts: 10
Joined: 08 May 2020, 23:33

Re: 3d Polyline points mismatch

Post by AlexBV » 04 Jul 2020, 06:10

Hello !! I am so happy, I think I found the way for both issues:.

In order to extract Coordinates, you have to assign the entity to a polyline in the following fashion (see the code).. and then everything works perfect !!
Here is the code and is working in all cases:

Cheers

Alex

if tEnt is TsgCADBasePolyline then
begin
if tEnt is TsgDXFPolyline then
begin
tDWGPL2 := TsgDXFPolyline(tEnt); //TDWGPL2 is defined as TsgSXFPolyline
With InpDigLine do Begin
Npts := tDWGPL2.PolyPoints.Count;
for j := 0 to Npts-1 do Begin
Data[j+1].XY.X := tDWGPL2.PolyPoints[j].X;
Data[j+1].XY.Y := tDWGPL2.PolyPoints[j].Y;
Data[j+1].Z := tDWGPL2.PolyPoints[j].z;
End;
if tDWGPL2.Closed then Begin
Inc(Npts);
Data[Npts] := Data[1];
End;
End;
End;
End;

Post Reply