How to change ATTDEF

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

Moderators: SDS, support, admin

Post Reply
hustwjz
Posts: 9
Joined: 30 Mar 2006, 05:48
Location: China

How to change ATTDEF

Post by hustwjz » 31 Aug 2006, 12:18

Hi,
I hope to change ATTDEF with following code.
AEnt: TsgDXFEntity;
ADef: TsgDXFAttdef;
.....
if (AEnt is TsgDXFAttdef)
begin
ADef := AEnt as TsgDXFAttdef;
ShowMessage(ADef.Tag + ':' + ADef.Text);
ADef.Text := 'hello attdef';
//ADef.Tag := 'hello attdef';
//Adef.Visible := FALSE;
EntList.Loads(ADef);
end
.....
From the message box, I knows that ADef was changed. But whatever I refresh the image, ADef is still showing its initial text (or tag )
Why the Visible property doesn't work? How can I change ATTDEF? Please give me a example.
Thank you in advance.

Thought that I found a powerfull CAD tool, keep on testing.....

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

Post by support » 31 Aug 2006, 20:22

Hello!
<br />Thank you for the useful remark.
This bug has been solved. Corrected (beta) version of CADImportVCL is available on: http://www.cadsofttools.com/download/CA ... _08_06.zip
<br />Please try is with the following code:

Code: Select all

<b>procedure</b> TMyApp.Forum_313_ButtonClick(Sender: TObject);
<b>var</b>
  I: Integer;
  vImg: TsgDXFImage;
  vAttDef: TsgDXFAttdef;
  vInvRect: TRect;
  S: <b>string</b>;
<b>begin
  if not</b> OpenDialog1.Execute <b>then</b>
    Exit;

  sgImage1.LoadFromFile(OpenDialog1.FileName);
  <b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then
  begin</b>
    sgImage1.Align := alClient;
    Img := TsgDXFImage(sgImage1.Picture.Graphic);
  <b>end
  else
  begin</b>
    Img := <b>nil</b>;
    Exit;
  <b>end</b>;

  <b>for</b> I := 0 <b>to</b> Img.Converter.Sections[csEntities].Count - 1 <b>do
  begin
    if</b> Img.Converter.Sections[csEntities].Entities[I] <b>is</b> TsgDXFAttdef <b>then
      begin</b>
        vAttDef := TsgDXFAttdef(Img.Converter.Sections[csEntities].Entities[I]);
        S := S + 'TsgDXFAttdef.Text = ' + vAttDef.Text + #13#10;
        S := S + 'TsgDXFAttdef.Tag = ' + vAttDef.Tag + #13#10;
      <b>end</b>;
  <b>end</b>;

  <b>if</b> vAttDef = <b>nil then</b>
    Exit;
  ShowMessage(S);
  vAttDef.Text := 'hello attdef';
  vAttDef.Tag  := 'hello attdef';
  S := S + 'TsgDXFAttdef.Text = ' + vAttDef.Text + #13#10;
  S := S + 'TsgDXFAttdef.Tag = ' + vAttDef.Tag + #13#10;
  Img.Converter.Loads(vAttDef);
  ShowMessage(S);
  vInvRect := sgImage1.PictureRect;
  InvalidateRect(sgImage1.Parent.Handle, @vInvRect, False);
<b>end</b>;
Sergey.

please post questions to the forum or write to support@cadsofttools.com

hustwjz
Posts: 9
Joined: 30 Mar 2006, 05:48
Location: China

Post by hustwjz » 01 Sep 2006, 05:34

Then, how about the 'Visible' property?
From user manual I know this property is read-write, but after I change it to 'FALSE', the entity is still showing.

Thought that I found a powerfull CAD tool, keep on testing.....

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

Post by support » 01 Sep 2006, 15:46

Hi,

Property <b>Visible</b> works for <b>TsgDXFLayer</b> only. This is made for compatibility with old versions of the library. To set visibility of the <b>ATTDEF</b> entity use property <b>TsgDXFAttdef.Visibility</b>.

Sergey.


please post questions to the forum or write to support@cadsofttools.com

Post Reply