AddScaledDXF question
Moderators: SDS, support, admin
AddScaledDXF question
Dear Sergey,
I have managed to superimpose a second .dxf drawing over the original drawing by means of AddScaledDXF but I can not delete this superimposed drawing after I have done using it. I have tried with DeleteEntity but to no avail. Please help.
Regards,
George
I have managed to superimpose a second .dxf drawing over the original drawing by means of AddScaledDXF but I can not delete this superimposed drawing after I have done using it. I have tried with DeleteEntity but to no avail. Please help.
Regards,
George
Dear George,
Please use the following example. Note: we use here <b>AddScaledDXFEx</b> function instead of <b>AddScaledDXF</b>.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please use the following example. Note: we use here <b>AddScaledDXFEx</b> function instead of <b>AddScaledDXF</b>.
Code: Select all
<b>uses</b>
...
DXFImage, DXFConv, SGImage, sgConsts;
<b>type</b>
TForm1 = <b>class</b>(TForm)
...
Button1: TButton;
Button2: TButton;
sgImage1: TsgImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
<b>private</b>
{ Private declarations }
Img, Img2: TsgDXFImage;
<b>public</b>
{ Public declarations }
<b>end</b>;
...
<b>procedure</b> TForm2.Button1Click(Sender: TObject);
<b>var</b>
P: TFPoint;
<b>begin</b>
sgImage1.LoadFromFile('c:\test.dxf');
Img := TsgDXFImage(sgImage1.Picture.Graphic);
sgImage1.Align := alClient;
P := MakeFPoint(Img.Extents.Left, Img.Extents.Bottom, 0);
Img2 := TsgDXFImage.Create;
Img2.LoadFromFile('c:\xreftest.dxf');
Img.AddScaledDXFEx(Img2,'xreftest.dxf',P,MakeFPoint(1,1,1),0.0);
<b>end</b>;
<b>procedure</b> TForm2.Button2Click(Sender: TObject);
<b>var</b>
vIns: TsgDXFInsert;
vBlock: TsgDXFBlock;
<b>function</b> GetInsert(<b>const</b> AName: string): TsgDXFInsert;
<b>var</b>
I, J: Integer;
vLayout: TsgDXFLayout;
<b>function</b> IsInsert(<b>const</b> AEnt: TsgDXFEntity): Boolean;
<b>var</b>
vInsert: TsgDXFInsert <b>absolute</b> AEnt;
<b>begin</b>
Result := (vInsert.Block <> <b>nil</b>) <b>and</b> (vInsert.Block.Name = AName)
<b>end</b>;
<b>begin</b>
Result := <b>nil</b>;
<b>for</b> I := Img.CurrentLayout.Count - 1 <b>downto</b> 0 <b>do
begin
if</b> IsInsert(Img.CurrentLayout.Entities[I]) <b>then
begin</b>
Result := TsgDXFInsert(Img.CurrentLayout.Entities[I]);
Break;
<b>end</b>;
<b>end</b>;
<b>if</b> Result <> <b>nil then</b> Exit;
<b>for</b> I := Img.LayoutsCount - 1 <b>downto</b> 0 <b>do
begin</b>
vLayout := Img.Layouts[I];
<b>if</b> vLayout = Img.CurrentLayout <b>then</b> Continue;
<b>for</b> J := vLayout.Count - 1 <b>downto</b> 0 <b>do
begin
if</b> IsInsert(vLayout.Entities[I])<b>then
begin</b>
Result := TsgDXFInsert(vLayout.Entities[I]);
Break;
<b>end</b>;
<b>end</b>;
<b>if</b> Result <> <b>nil then</b> Break;
<b>end</b>;
<b>end</b>;
<b>begin
if</b> Img = <b>nil then</b>
Exit;
vIns := GetInsert('xreftest.dxf');
vBlock := vIns.Block;
vIns.Block := <b>nil</b>;
Img.Converter.DeleteBlock(vBlock, True);
<b>end</b>;
<b>end</b>.
please post questions to the forum or write to support@cadsofttools.com