3d Polyline points mismatch
Posted: 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
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