Insert image failed with V7
Posted: 24 Jul 2009, 17:13
Hello,
I try the new version of cadimport.dll (Version 7.2.1.21993) but some code doesn't work now.
With previous version ( V6.3.2942.31653), i manage to insert image with the following code :
cadPictBox.DoubleBuffering = false;
CADLayer entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Flags = 4;
this.cadImage.Converter.Layers.Add(entLayer);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.Converter.Loads(entLayer);
//creation block
CADBlock bl1 = new CADBlock();
string sBlockName = "blimage";
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
if (bl1 == null)
bl1 = new CADBlock();
bl1.Name = sBlockName;
bl1.Color = CADConst.clNone;
bl1.Visibility = true;
bl1.Visible = true;
bl1.Layer = entLayer;
//creation image
CADImageEnt image = new CADImageEnt();
Image imageObj = null;
double dbHeightImage = 38;
imageObj = System.Drawing.Image.FromFile(@"c:\tmp\GenComposant.JPG");
image.SetImage(imageObj);
image.Color = Color.Bisque;
image.Point = new DPoint(0, 0, 0);
image.Point1 = new DPoint(dbHeightImage, -dbHeightImage, 0);
image.Point2 = new DPoint(0, 0, 0);
image.Point3 = new DPoint(1, 1, 1);
image.Rotate = 0;
image.LineWeight = 0.1;
image.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(image);
bl1.AddEntity(image);
//load block
this.cadImage.Converter.Blocks.Add(bl1);
this.cadImage.Converter.OnCreate(bl1);
this.cadImage.Converter.Loads(bl1);
//creation + load insert
CADInsert ins1 = new CADInsert();
ins1.Block = bl1;
ins1.Point = new DPoint(System.Convert.ToDouble(txtPosX.Text), System.Convert.ToDouble(txtPosY.Text), 0);
ins1.Visibility = true;
ins1.Layer = entLayer;
this.cadImage.Converter.Entities.Add(ins1);
this.cadImage.Converter.OnCreate(ins1);
this.cadImage.Converter.Loads(ins1);
this.cadPictBox.Invalidate();
Now image doesn't appear in the dwg map.
Moreover even if call two times the code, the following line return always null (but not in V6):
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
So i think, i don't manage to insert block with the new version.
Please could you explain me what is wrong.
Thanks, yannick
I try the new version of cadimport.dll (Version 7.2.1.21993) but some code doesn't work now.
With previous version ( V6.3.2942.31653), i manage to insert image with the following code :
cadPictBox.DoubleBuffering = false;
CADLayer entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Flags = 4;
this.cadImage.Converter.Layers.Add(entLayer);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.Converter.Loads(entLayer);
//creation block
CADBlock bl1 = new CADBlock();
string sBlockName = "blimage";
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
if (bl1 == null)
bl1 = new CADBlock();
bl1.Name = sBlockName;
bl1.Color = CADConst.clNone;
bl1.Visibility = true;
bl1.Visible = true;
bl1.Layer = entLayer;
//creation image
CADImageEnt image = new CADImageEnt();
Image imageObj = null;
double dbHeightImage = 38;
imageObj = System.Drawing.Image.FromFile(@"c:\tmp\GenComposant.JPG");
image.SetImage(imageObj);
image.Color = Color.Bisque;
image.Point = new DPoint(0, 0, 0);
image.Point1 = new DPoint(dbHeightImage, -dbHeightImage, 0);
image.Point2 = new DPoint(0, 0, 0);
image.Point3 = new DPoint(1, 1, 1);
image.Rotate = 0;
image.LineWeight = 0.1;
image.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(image);
bl1.AddEntity(image);
//load block
this.cadImage.Converter.Blocks.Add(bl1);
this.cadImage.Converter.OnCreate(bl1);
this.cadImage.Converter.Loads(bl1);
//creation + load insert
CADInsert ins1 = new CADInsert();
ins1.Block = bl1;
ins1.Point = new DPoint(System.Convert.ToDouble(txtPosX.Text), System.Convert.ToDouble(txtPosY.Text), 0);
ins1.Visibility = true;
ins1.Layer = entLayer;
this.cadImage.Converter.Entities.Add(ins1);
this.cadImage.Converter.OnCreate(ins1);
this.cadImage.Converter.Loads(ins1);
this.cadPictBox.Invalidate();
Now image doesn't appear in the dwg map.
Moreover even if call two times the code, the following line return always null (but not in V6):
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
So i think, i don't manage to insert block with the new version.
Please could you explain me what is wrong.
Thanks, yannick