Error adding TsgDXFImageEnt
Moderators: SDS, support, admin
Error adding TsgDXFImageEnt
Hi:
I have modified the example "Delphi\Demos\Add new entities", to add a type entity "TsgDXFImageEnt." But when exit the application I obtain the following error:
"Exception EInvalidPointer in module rtl100.bpl at 00006581. Invalid pointer operation."
Thank you,
Roberto
I have modified the example "Delphi\Demos\Add new entities", to add a type entity "TsgDXFImageEnt." But when exit the application I obtain the following error:
"Exception EInvalidPointer in module rtl100.bpl at 00006581. Invalid pointer operation."
Thank you,
Roberto
Code: Select all
<b>procedure</b> TfmMain.btnNewClick(Sender: TObject);
<b>var</b>
Ent: TsgDXFImageEnt;
ADXFImage: TsgDXFImage;
EDef : TsgDXFImageDef;
<b>begin
if not</b> (sgCADImage.Picture.Graphic <b>is</b> TsgDXFImage) <b>then</b>
Exit;
<i>{ Im := TsgDXFImage(sgCADImage.Picture.Graphic);
Ent := GetEntity;
if Ent <> nil then
begin
Im.Converter.Sections[csEntities].AddEntity(Ent);
if Assigned(Im.Converter.OnCreate) then
Im.Converter.OnCreate(Ent);
Im.Converter.Loads(Ent);
Im.GetExtents;
sgCADImage.Refresh;
FLastAdded := Ent;
end;}</i>
ADXFImage := TsgDXFImage(sgCADImage.Picture.Graphic);
EDef := TsgDXFImageDef.Create;
EDef.FileName := 'c:\temp\image.bmp';
EDef.Picture.LoadFromFile('c:\temp\image.bmp');
EDef.Handle := ADXFImage.Converter.ImageDefCount;
ADXFImage.Converter.Sections[csEntities].AddEntity(EDef);
<b>if</b> Assigned(ADXFImage.Converter.OnCreate) <b>then</b>
ADXFImage.Converter.OnCreate(EDef);
ADXFImage.Converter.Loads(EDef);
Ent := TsgDXFImageEnt.Create;
Ent.Point := MakeFPoint(0,0,0);
Ent.Point1 :=MakeFPoint(3,0,0); //width
Ent.Point2 := MakeFPoint(0,3,0); //heigth
Ent.Point3 := MakeFPoint(1,1,1); //scale
Ent.ImageDef := EDef.Handle;
Ent.FindPicture(ADXFImage.Converter);
ADXFImage.Converter.Sections[csEntities].AddEntity(Ent);
<b>if</b> Assigned(ADXFImage.Converter.OnCreate) <b>then</b>
ADXFImage.Converter.OnCreate(Ent);
ADXFImage.Converter.Loads(Ent);
ADXFImage.GetExtents;
sgCADImage.Refresh;
FLastAdded := Ent;
<b>end</b>;
Dear Roberto!
Could you please inform us what version of Delphi do you use?
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Could you please inform us what version of Delphi do you use?
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Hello Reberto!
It is necessary to register a class for opening files of BMP format:
- add after <b>uses</b> the following:
- add at the end of module the following:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
It is necessary to register a class for opening files of BMP format:
- add after <b>uses</b> the following:
Code: Select all
<b>const</b>
SBMPImage = 'Windows BitMap image';
<b>var</b>
CF_BMP: Word;
Code: Select all
<b>initialization</b>
CF_BMP := RegisterClipboardFormat('BMP Image');
TPicture.RegisterClipboardFormat(CF_BMP, TBitMap);
TPicture.RegisterFileFormat('bmp', SBMPImage, TBitMap);
<b>finalization</b>
TPicture.UnRegisterGraphicClass(TBitMap);
please post questions to the forum or write to support@cadsofttools.com
Dear Sergey:
I have not been able to solve the problem. The image is shown correctly on screen, the error is when I close the application.
Stack list in my application (not in the Demo):
[51F2657C] System.System.TObject.FreeInstance (Line 8830, "system.pas" + 2) + $2
[51F23DEE] System.System.ErrorAt (Line 3285, "system.pas" + 3) + $4
[51F2657C] System.System.TObject.FreeInstance (Line 8830, "system.pas" + 2) + $2
[51F269AE] System.System.@ClassDestroy (Line 9530, "system.pas" + 0) + $2
[008022D1] sgBitmap.sgBitmap.TsgBitmap.Destroy + $25
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[52009E4E] Graphics.Graphics.TPicture.Destroy (Line 4009, "Graphics.pas" + 1) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[00842DD6] DXFConv.DXFConv.TsgDXFImageDef.Destroy + $E
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[007F4055] sgConsts.sgConsts.ClearList + $1D
[0082B5F4] DXFConv.DXFConv.TsgDXFConverter.Clear + $3C
[0082B521] DXFConv.DXFConv.TsgDXFConverter.Destroy + $D
[0084CF7A] DWG.DWG.TsgDWGConverter.Destroy + $42
[0082BFBF] DXFConv.DXFConv.TsgDXFConverter.Release + $33
[0081987E] DXFImage.DXFImage.TsgDXFImage.Destroy (Line 587, "DXFImage.pas" + 10) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[52009E4E] Graphics.Graphics.TPicture.Destroy (Line 4009, "Graphics.pas" + 1) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[5202CF3D] ExtCtrls.ExtCtrls.TImage.Destroy (Line 1820, "ExtCtrls.pas" + 1) + $6
[00866455] SGImage.SGImage.TsgImage.Destroy + $19
[5205A531] Controls.Controls.TWinControl.Destroy (Line 6034, "Controls.pas" + 16) + $6
[5206F07C] Forms.Forms.TScrollingWinControl.Destroy (Line 2212, "Forms.pas" + 3) + $7
[5207011E] Forms.Forms.TCustomForm.Destroy (Line 2746, "Forms.pas" + 12) + $A
[52070139] Forms.Forms.TCustomForm.Destroy (Line 2748, "Forms.pas" + 14) + $9
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[0AE00734] bkDXFPreviewForm.bkDXFPreviewForm.Print + $A0
Thank you,
Roberto
I have not been able to solve the problem. The image is shown correctly on screen, the error is when I close the application.
Stack list in my application (not in the Demo):
[51F2657C] System.System.TObject.FreeInstance (Line 8830, "system.pas" + 2) + $2
[51F23DEE] System.System.ErrorAt (Line 3285, "system.pas" + 3) + $4
[51F2657C] System.System.TObject.FreeInstance (Line 8830, "system.pas" + 2) + $2
[51F269AE] System.System.@ClassDestroy (Line 9530, "system.pas" + 0) + $2
[008022D1] sgBitmap.sgBitmap.TsgBitmap.Destroy + $25
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[52009E4E] Graphics.Graphics.TPicture.Destroy (Line 4009, "Graphics.pas" + 1) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[00842DD6] DXFConv.DXFConv.TsgDXFImageDef.Destroy + $E
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[007F4055] sgConsts.sgConsts.ClearList + $1D
[0082B5F4] DXFConv.DXFConv.TsgDXFConverter.Clear + $3C
[0082B521] DXFConv.DXFConv.TsgDXFConverter.Destroy + $D
[0084CF7A] DWG.DWG.TsgDWGConverter.Destroy + $42
[0082BFBF] DXFConv.DXFConv.TsgDXFConverter.Release + $33
[0081987E] DXFImage.DXFImage.TsgDXFImage.Destroy (Line 587, "DXFImage.pas" + 10) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[52009E4E] Graphics.Graphics.TPicture.Destroy (Line 4009, "Graphics.pas" + 1) + $3
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[5202CF3D] ExtCtrls.ExtCtrls.TImage.Destroy (Line 1820, "ExtCtrls.pas" + 1) + $6
[00866455] SGImage.SGImage.TsgImage.Destroy + $19
[5205A531] Controls.Controls.TWinControl.Destroy (Line 6034, "Controls.pas" + 16) + $6
[5206F07C] Forms.Forms.TScrollingWinControl.Destroy (Line 2212, "Forms.pas" + 3) + $7
[5207011E] Forms.Forms.TCustomForm.Destroy (Line 2746, "Forms.pas" + 12) + $A
[52070139] Forms.Forms.TCustomForm.Destroy (Line 2748, "Forms.pas" + 14) + $9
[51F265C4] System.System.TObject.Free (Line 8849, "system.pas" + 1) + $4
[0AE00734] bkDXFPreviewForm.bkDXFPreviewForm.Print + $A0
Thank you,
Roberto
Dear Roberto,
Please try the following code as it is, without registration described in our previous post:
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please try the following code as it is, without registration described in our previous post:
Code: Select all
<b>procedure</b> TfmMain.btnNewClick(Sender: TObject);
<b>var</b>
Ent: TsgDXFImageEnt;
ADXFImage: TsgDXFImage;
EDef : TsgDXFImageDef;
vRect: TfRect;
<b>begin
if not</b> (sgCADImage.Picture.Graphic <b>is</b> TsgDXFImage) <b>then</b>
Exit;
ADXFImage := TsgDXFImage(sgCADImage.Picture.Graphic);
ADXFImage.CurrentLayout.PaperSpaceBlock.IsLoaded := False;
EDef := TsgDXFImageDef.Create;
EDef.FileName := 'c:\temp\image.bmp';
EDef.Picture.LoadFromFile('c:\temp\image.bmp');
EDef.Handle := ADXFImage.Converter.ImageDefCount;
ADXFImage.Converter.Loads(EDef);
<b>if not</b> (ADXFImage <b>is</b> TsgDWGImage) <b>then</b>
ADXFImage.CurrentLayout.AddEntity(EDef);
vRect := ADXFImage.Extents;
Ent := TsgDXFImageEnt.Create;
Ent.Point := MakeFPoint((vRect.Left + vRect.Bottom) * 0.5,
(vRect.Top + vRect.Bottom) * 0.5,
(vRect.Z1 + vRect.Z2) * 0.5);
Ent.Point := MakeFPoint((vRect.Left + vRect.Right) * 0.5,
(vRect.Top + vRect.Bottom) * 0.5, (vRect.Z1 + vRect.Z2) * 0.5);
Ent.Point1 :=MakeFPoint(EDef.Picture.Width,0,0); //width
Ent.Point2 := MakeFPoint(0,EDef.Picture.Height,0); //heigth
Ent.Point3 := MakeFPoint(1,1,1); //scale
Ent.ImageDef := EDef.Handle;
Ent.FindPicture(ADXFImage.Converter);
ADXFImage.Converter.Loads(Ent);
ADXFImage.CurrentLayout.AddEntity(Ent);
ADXFImage.Converter.Loads(ADXFImage.CurrentLayout);
ADXFImage.Converter.Loads(ADXFImage.CurrentLayout);
ADXFImage.GetExtents;
sgCADImage.Refresh;
FLastAdded := Ent;
<b>end</b>;
please post questions to the forum or write to support@cadsofttools.com
Dear Segey:
The code that he send me doesn't work, ADXFImage.CurrentLayout.PaperSpaceBlock is always NIL. If I put the you line in comment, the image is not shown in the viewer.
<font color="purple">Spanish:
El cуdigo que me envнa no funciona, ADXFImage.CurrentLayout.PaperSpaceBlock es siempre NIL. Si pongo la linea en comentario, la imagen no se muestra en el visor.</font id="purple">
Thank you,
Roberto
Spain
The code that he send me doesn't work, ADXFImage.CurrentLayout.PaperSpaceBlock is always NIL. If I put the you line in comment, the image is not shown in the viewer.
<font color="purple">Spanish:
El cуdigo que me envнa no funciona, ADXFImage.CurrentLayout.PaperSpaceBlock es siempre NIL. Si pongo la linea en comentario, la imagen no se muestra en el visor.</font id="purple">
Thank you,
Roberto
Spain
Dear Roberto,
Please compile your application with CADImportVCL beta version: http://www.cadsofttools.com/download/CA ... _08_06.zip
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please compile your application with CADImportVCL beta version: http://www.cadsofttools.com/download/CA ... _08_06.zip
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Hello Roberto!
Please contact us to info@cadsofttools.com with a reference to this topic.
Sergey.
please post questions to the forum or write to support@cadsofttools.com
Please contact us to info@cadsofttools.com with a reference to this topic.
Sergey.
please post questions to the forum or write to support@cadsofttools.com