Copying entities from a layout to a new DXFImage
Moderators: SDS, support, admin
Copying entities from a layout to a new DXFImage
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??[:)]
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??[:)]
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
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
Hi again, I've modified the Editor demo and added a combobox with the list of layouts to change from one layout to another:
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:
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:
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
Code: Select all
<b>procedure</b> TfmMain.cblayoutsChange(Sender: TObject);
<b>begin</b>
img.CurrentLayout:=img.Layouts[cblayouts.itemindex];
<b>end</b>;
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>;
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>;
All this is working perfectly with the layout "model" but not with the others.
Thanks
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:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
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 !!!
please post questions to the forum or write to support@cadsofttools.com