Copying entities from a layout to a new DXFImage

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

Moderators: SDS, support, admin

Post Reply
Laker32
Posts: 8
Joined: 07 Aug 2006, 22:14
Location: USA

Copying entities from a layout to a new DXFImage

Post by Laker32 » 07 Aug 2006, 22:32

Hi!, I'm checking out your component in delphi and I need to add a feature to a program I'm developing.

I need to select and copy some entities from a specific layout and save them to a emf file.

I've checked the "Editor" demo and does the work fine using the selection manager and 1 layout, the problem is that it doesn't work with different layouts, when I select a different layout than the default one the resulting image apears empty. It looks like the selection manager actually contains the list of the entities, and when the fillimage routine is called the entities are added to the new DXFImage, so I can't understand what's happening.

Could you help me please??[:)]

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

Post by support » 08 Aug 2006, 14:08

Hello!

You are absolutely right, demo <b>Editor</b> works with the only layout called <b>Model</b>. Also as you say it creates a new DXFImage for viewing selected entities (select some entities and press button <b>Preview selection</b>).

Could you please explain what task do you have and what do you try to do (your code will be appreciated).

Sergey.

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

Laker32
Posts: 8
Joined: 07 Aug 2006, 22:14
Location: USA

Post by Laker32 » 08 Aug 2006, 18:33

Hi again, I've modified the Editor demo and added a combobox with the list of layouts to change from one layout to another:

Code: Select all

<b>procedure</b> TfmMain.cblayoutsChange(Sender: TObject);
<b>begin</b>
   img.CurrentLayout:=img.Layouts[cblayouts.itemindex];
<b>end</b>;
I have one dwg file with a layout called "model" and other called "v-002".

In this demo there is a selection manager that creates a list of entities in the selection and when we push the "Preview selection button" a window is shown:

Code: Select all

<b>procedure</b> TfmMain.Preview1Click(Sender: TObject);
<b>begin</b>
  CreatePreview(Self, FManager, TsgDXFImage(sgImage.Picture.Graphic));
<b>end</b>;
There is a "FillImage" routine that creates the preview image.

Problem: The selection manager looks like is working but when I select the second layout("v-002") and press the "Preview Selection" button the preview window shows an Empty Image.

Final Task: I need to save the image to a wmf or emf file with a button from the preview window:

Code: Select all

<b>procedure</b> TfmPreview.btnCancelClick(Sender: TObject);
<b>var</b>
  mf:tmetafile;
<b>begin</b>
   mf:=TsgDXFImage(sgimage.Picture.Graphic).ExportToMetafile(3000000);
   mf.SaveToFile('c:\selection.emf');
   mf.Free;
<b>end</b>;
But as you can see if the sgImage is empty the outputfile will be too.

All this is working perfectly with the layout "model" but not with the others.

Thanks

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

Post by support » 21 Aug 2006, 15:29

Hello all!

When it is necessary to add layout's support into the <b>Editor</b> demo then PaperSpace has to be nullified (we will improve the logic of work with PaperSpace in future version).

Add the following lines to ..\cadimportvcl\Delphi\Demos\Editor\fPreview.pas:

Code: Select all

<b>procedure</b> TfmPreview.FillImage(ASManager: TsgSelectionManager;
  ADXFImage: TsgDXFImage);
...
    vEnt.AssignEntity(TsgDXFEntity(FSManager.SelectedEntities[I]));
    vEnt.PaperSpace := 0;// !!! INSERTED !!!
Sergey.

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

Post Reply