How to add a CADImageEnt?

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
vcomer
Posts: 6
Joined: 08 Mar 2011, 04:38

How to add a CADImageEnt?

Post by vcomer » 12 Mar 2011, 10:57

How to Add a CADImageEnt? Not use EntitiesCreator.
There is no code in AddEntityDemo.
who know?
Thanks!

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

Re: How to add a CADImageEnt?

Post by support » 15 Mar 2011, 11:42

Hello.
You can use the following code snippet:

Code: Select all

    public class MainForm : System.Windows.Forms.Form
    {
        ...
        private CADImport.CADImage cadImage;
        private CADPictureBox cadPictBox;
        ...

        private void miAbout_Click(object sender, System.EventArgs e)
        {
			 if (this.cadImage == null)
			 {
			 	this.cadImage = new CADImage();
			 	this.cadImage.InitialNewImage();
			 }

          CADImageEnt entRaster = new CADImageEnt();
          string tmp = "c:\\Users\\Support.CST\\Pictures\\viewer.bmp ";
          Bitmap bmpTmp;
          if (!System.IO.File.Exists(tmp)) return;            
          try
          {
             bmpTmp = new Bitmap(tmp);
          }
          catch
          {
             return;
          }
          CADImageDef def = new CADImageDef();
          def.FileName = tmp;
          def.Loaded(this.cadImage.Converter);            
          entRaster.ImageDef = def;            
          entRaster.Color = CADConst.clNone;
          entRaster.Point = new DPoint(0, 0, 0);
          entRaster.Size = new DPoint(bmpTmp.Width, bmpTmp.Height, 0);            
          entRaster.Rotate = 0;
          entRaster.Loaded(this.cadImage.Converter);

          this.cadImage.Converter.ImageDefs.Add(entRaster.ImageDef);
          this.cadImage.Converter.OnCreate(entRaster);
          this.cadImage.CurrentLayout.AddEntity(entRaster);

          this.cadImage.GetExtents();
          this.cadPictBox.Invalidate();
        }
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

vcomer
Posts: 6
Joined: 08 Mar 2011, 04:38

Re: How to add a CADImageEnt?

Post by vcomer » 16 Mar 2011, 12:08

thanks,now I can create CADImageEnt! :P
but, there is a new problem:
when I add a new cadImageEnt using "c:\viewer.bmp ", and save the file as **.dxf;
then I delete the picture file(c:\viewer.bmp) and reopen the **.dxf ,
the new added cadImageEnt exit,but have no image! :oops:
why?

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

Re: How to add a CADImageEnt?

Post by support » 17 Mar 2011, 15:42

Hello.
DWG/DXF specification determines a raster image as a form of external reference. The raster drawing not added to AutoCAD file but loaded from stored raster file that must be present on hard disk.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

vcomer
Posts: 6
Joined: 08 Mar 2011, 04:38

Re: How to add a CADImageEnt?

Post by vcomer » 18 Mar 2011, 05:49

Understand,thanks!
now,
I need draw a selected cadImageEnt in the center of the CADPictureBox in given scale.(like google earth)
how to do it?(how to calculate "LeftImagePosition" and "TopImagePosition")

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

Re: How to add a CADImageEnt?

Post by support » 23 Mar 2011, 12:14

Hello.
The following topic contains code snippet for scaling specified entity to CADPictureBox client area:
http://www.cadsofttools.com/forum/viewt ... =15&t=1382

Just set the required scale: Me.ImageScale = kf1 / X //the X value will define the scale factor for visualization.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply