Move TsgDXFEntity
Moderators: SDS, support, admin
Move TsgDXFEntity
I have added by means of AddEntity a TsgDXFSpline on TsgDXFImage.
How I can move this spline on X and Y?
How I can move this spline on X and Y?
Hello Yura,
The following code allows moving TsgDXFSpline entity 20 pixels to the right and 20 pixels to the bottom:
<b>Note:</b> the code above will be available in a demo programm in the next update of <b>CADImportVCL</b>.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
The following code allows moving TsgDXFSpline entity 20 pixels to the right and 20 pixels to the bottom:
Code: Select all
<b>procedure</b> TForm1.MovingTsgDXFSplineClick(Sender: TObject);
<b>var</b>
vImg: TsgDXFImage;
vEnt: TsgDXFEntity;
I, vCnt: Integer;
<b>procedure</b> MovingSpline(ASpline: TsgDXFSpline; <b>const</b> APt: TFPoint);
<b>var</b>
J: Integer;
vPt: PFPoint;
<b>begin
for</b> J := ASpline.Controls.Count - 1 <b>downto</b> 0 <b>do
begin</b>
vPt := ASpline.Controls[J];
vPt^.X := vPt^.X + APt.X;
vPt^.Y := vPt^.Y + APt.Y;
vPt^.Z := vPt^.Z + APt.Z;
<b>end</b>;
<b>for</b> J := ASpline.Fit.Count - 1 <b>downto</b> 0 <b>do
begin</b>
vPt := ASpline.Fit[J];
vPt^.X := vPt^.X + APt.X;
vPt^.Y := vPt^.Y + APt.Y;
vPt^.Z := vPt^.Z + APt.Z;
<b>end</b>;
vImg.Converter.Loads(ASpline);
<b>end</b>;
<b>begin</b>
vImg := TsgDXFImage(sgPaintBox.Picture.Graphic);
<b>if</b> vImg = <b>nil then</b> Exit;
vCnt := vImg.Converter.Counts[csEntities];
I := 0;
<b>while</b> I < vCnt <b>do
begin</b>
vEnt := vImg.Converter.Sections[csEntities].Entities[I];
<b>if</b> (vEnt.ClassType = TsgDXFSpline) <b>then</b>
MovingSpline(TsgDXFSpline(vEnt), MakeFPoint(20,-20,0));
Inc(I);
<b>end</b>;
sgPaintBox.Invalidate;
<b>end</b>;
Sergey.
please post questions to the forum or write to support@cadsofttools.com