Another question about copy/paste blocks !

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

Moderators: SDS, support, admin

Post Reply
Jourde
Posts: 33
Joined: 10 Sep 2004, 10:33
Location: France
Contact:

Another question about copy/paste blocks !

Post by Jourde » 16 Jan 2006, 12:07

Hi,

i succes copy/paste block from a tsgimage to another tsgimage using your sample. But with this methode we need to copy all values from the source entities to the new entities (And lots of thing are needed, and the result don't show exactly the same than with the reader).

It would be possible to say like :
Img_Travail.Converter.Sections[csBlocks].AddEntity(vBlock,false);

Where 'false' to says to the converter that this block is not store in it, then i don't have to free this entities.

This because, when i have a data_base_of_block (in a sgimage) and if i use a sgimage to work after destroy the working form, then all blocks in the data_base (sgimage)are free !

it is possible ?

Thanks

E. Jourde

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

Post by support » 17 Jan 2006, 12:23

Hello,

Thank you for the question. It is rather interesting. We'll prepare the answer soon.

Sergey.

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

Jourde
Posts: 33
Joined: 10 Sep 2004, 10:33
Location: France
Contact:

Post by Jourde » 17 Jan 2006, 13:45

ok

i success copying some entyties, but i don't know with the documentation what field must be initialised to be ok for each class.

For sample for polyline i do this :

Code: Select all

      <b>If</b> vBlock.Entities[I] <b>Is</b> TsgDXFPolyline <b>Then</b>
      <b>Begin</b>
        vNewPoly := TsgDXFPolyline.Create;
        vPoly := TsgDXFPolyline(vBlock.Entities[I]);
        vNewPoly.Closed := vPoly.Closed;
        vNewPoly.MeshM := vPoly.MeshM;
        vNewPoly.MeshN := vPoly.MeshN;
        vNewPoly.SetColor(vPoly.Pen.Pen.Color);
        vNewPoly.Flags := vPoly.Flags;
        <b>If</b> vPoly.Pen <> <b>Nil Then
        Begin</b>
          vNewPoly.Pen.Pen.Color := vPoly.Pen.Pen.Color;
        <b>End</b>;
        <b>For</b> j := 0 <b>To</b> vPoly.Count - 1 <b>Do
        Begin</b>
          vVertex := TsgDXFVertex(vpoly.Entities[j]);
          vnewVertex := TsgDXFVertex.Create;
          vnewVertex.Point := vVertex.Point;
          vNewPoly.AddEntity(vNewVertex);
        <b>End</b>;
        <b>If</b> vPoly.Layer <> <b>Nil Then
        Begin</b>
          vNewPoly.Layer := cont.Donne_Layer(vPoly.Layer.Name); -> this copy the layer and add it automaticly ans return a layer
          vNewPoly.Layer.SetColor(vPoly.Layer.Pen.Color);
        <b>End</b>;
        vNewBlock.AddEntity(vNewPoly);
      <b>End</b>;
But how can i know if it's the minimal necessary ! need else ?

I says this because my copy don't look excatly the same than your viewer ! i must missed something !

And it's begin more difficult when trying to do the same with a Hatch entyties.

Thanks

E.Jourde

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

Post by support » 20 Jan 2006, 11:58

Hello,

1. Generally saying the following line is enough for block section should not be deleted:
Img_Travail.Converter.Sections[csBlocks] := nil;
the section itself must be saved and deleted "manually" somewhere in the other place. But it will be necessary to test the code for every specific case (we can not repeat your way of managing with the sgImage).
We can add such function but it will demand adding of a new field to the block class (FIsDoFree: Boolean). We'd like to avoid such changes. But if there is no way for you without of such function we can make for you a special built package.

2. It is necessary to reload after entity's coping:
Converter.Loads;
We plan to implement a coping method (Assign) for every entity.

Sergey.

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

Post Reply