I'm evaluating the CadImport VCL and I'm interested in adding some images (not to be saved/exported in the DWG/DXF file).
I compiled without any issues the AddNew demo, and while I can add an entity in small DWG files (with some minor bugs, like initial squashed image that fixes itself when I change the zoom factor), in the DWG file I'm most insterested adding entities, when I click the Ok button, the drawing brokes (it makes itself tiny in a corner of the TImage), the new entity is nowere to be seen and the zoom in/zoom out functions cease to work.
The file itself is an DWG weighting about 2,8Mb, and I tried converting it to an 8,6Mb DXF with the same results.
There is any size/complexity limits to the add entity functions? or is an specific error of my file?
I'm using Delphi 2006 Win32.
Problems adding entities in the AddNew Demo
Moderators: SDS, support, admin
Hello!
Sorry for the delay.
Downwards goes simple demo which allows adding BMP files. Please try it.
BTW: <b>CAD Import VCL</b> (available at: http://www.cadsofttools.com/download/cadimportvcl.zip) contains <b>Add new entities demo</b>. You can find it in the ..\cadimportvcl\Delphi\Demos\Add new entities\.. folder of the package. Please study it.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Sorry for the delay.
Downwards goes simple demo which allows adding BMP files. Please try it.
Code: Select all
<b>uses</b>
... SGImage, DXFImage, DXFConv, sgConsts;
<b>type</b>
TForm1 = <b>class</b>(TForm)
Panel1: TPanel;
btnOpenCAD: TButton;
btnAddBMP: TButton;
sgImage1: TsgImage;
procedure btnOpenCADClick(Sender: TObject);
procedure btnAddBMPClick(Sender: TObject);
<b>private</b>
<font color="blue"><i>{ Private declarations }</i></font id="blue">
FImg: TsgDXFImage;
...
<b>procedure</b> TForm1.btnOpenCADClick(Sender: TObject);
<b>begin</b>
sgImage1.LoadFromFile(<font color="blue">'c:\Test.dxf'</font id="blue">);
<b>if</b> sgImage1.Picture.Graphic <b>is</b> TsgDXFImage <b>then
begin</b>
FImg := TsgDXFImage(sgImage1.Picture.Graphic);
sgImage1.Align := alClient;
<b>end
else</b>
FImg := <b>nil</b>;
<b>end</b>;
<b>procedure</b> TForm1.btnAddBMPClick(Sender: TObject);
<b>var</b>
Ent: TsgDXFEntity;
<b>function</b> GetBitMap: TsgDXFEntity;
<b>var</b>
vBitMap: TBitmap;
vImageEnt: TsgDXFImageEnt <b>absolute</b> Result;
<b>begin</b>
Result := <b>nil</b>;
vBitMap := TBitmap.Create;
<b>try</b>
vBitMap.LoadFromFile(<font color="blue">'c:\InsertPict.bmp'</font id="blue">);
<b>except</b>
vBitMap.Free;
Exit;
<b>end</b>;
vImageEnt := TsgDXFImageEnt.Create;
vImageEnt.Point := MakeFPoint(<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">,<font color="blue">0</font id="blue">);
vImageEnt.Point1 := MakeFPoint(vBitMap.Width, <font color="blue">0</font id="blue">, <font color="blue">0</font id="blue">);
vImageEnt.Point2 := MakeFPoint(<font color="blue">0</font id="blue">, vBitMap.Height, <font color="blue">0</font id="blue">);
vImageEnt.Point3 := MakeFPoint(<font color="blue">0.5</font id="blue">,<font color="blue">0.5</font id="blue">,<font color="blue">0.5</font id="blue">);
vImageEnt.SetImage(vBitMap);
vBitMap.Free;
<b>end</b>;
<b>begin
if</b> FImg = <b>nil then</b>
Exit;
Ent := GetBitMap;
<b>if</b> Ent <> <b>nil then
begin</b>
FImg.Converter.Sections[csEntities].AddEntity(Ent);
<b>if</b> Assigned(FImg.Converter.OnCreate) <b>then</b>
FImg.Converter.OnCreate(Ent);
FImg.Converter.Loads(Ent);
FImg.GetExtents;
FImg.RefreshCurrentLayout;
sgImage1.Width := FImg.Width;
sgImage1.Height := FImg.Height;
sgImage1.Align := alClient;
sgImage1.Invalidate;
<b>end</b>;
<b>end</b>;
<b>end</b>.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com