Insert image failed with V7
Moderators: SDS, support, admin
Insert image failed with V7
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
Re: Insert image failed with V7
Hello.
Due to changes in CAD Import .NET 7 the code that works well in CAD Import .NET 6 requires some modifications. You can use such code:
Alexander.
Due to changes in CAD Import .NET 7 the code that works well in CAD Import .NET 6 requires some modifications. You can use such code:
Code: Select all
if (this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
}
this.cadImage.UseDoubleBuffering = false;
CADLayer entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Flags = 4;
entLayer.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.CurrentLayout.AddEntity(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.Visibility = true;
bl1.Visible = true;
bl1.Layer = entLayer;
//creation image
Point p1 = new Point(0, 0);
Point p2 = new Point(100, 75);
Rectangle r1 = CADConst.SetNewRect(p1, p2);
DPoint pt1 = new DPoint(r1.Left, r1.Top, 0);
DPoint pt2 = new DPoint(r1.Right, r1.Bottom, 0);
CADImageEnt image = new CADImageEnt();
string path = @"c:\tmp\GenComposant.JPG";
Bitmap bmpTmp;
bmpTmp = new Bitmap(path);
CADImageDef def = new CADImageDef();
def.FileName = path;
this.cadImage.Converter.Loads(def);
image.ImageDef = def;
image.Point = new DPoint(pt1.X, pt1.Y, 0);
image.Size = new DPoint(r1.Width, r1.Height, 0);
image.Loaded(this.cadImage.Converter);
this.cadImage.Converter.ImageDefs.Add(image.ImageDef);
bl1.AddEntity(image);
//load block
bl1.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(bl1);
this.cadImage.CurrentLayout.AddEntity(bl1);
//creation + load insert
CADInsert ins1 = new CADInsert();
ins1.Block = bl1;
ins1.Point = new DPoint(0, 0, 0);
ins1.Visibility = true;
ins1.Layer = entLayer;
ins1.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(ins1);
this.cadImage.CurrentLayout.AddEntity(ins1);
this.cadPictBox.Invalidate();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Insert image failed with V7
I test with dll demo version 7.2.1.21993.
Your example works partially, now picture appears in the map.
For informations, the following code was the problem :
V6:
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);
With V7 we just need to remplace with :
image.Point = new DPoint(0, 0, 0);
image.Size = new DPoint(dbHeightImage, -dbHeightImage, 0);
But i still get bl1 with null after this line of code with your example when i call two times the code:
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
I get the same problem if i test this :
CADLayer entLayer = (CADLayer)cadImage.Converter.Layers["MyLayer"];
if (entLayer == null)
{
entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Flags = 4;
entLayer.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.CurrentLayout.AddEntity(entLayer);
}
I i call two times this code entLayer is always null after this:
CADLayer entLayer = (CADLayer)cadImage.Converter.Layers["MyLayer"];
But i didn't got this problem with V6.
Please could you explain me what is wrong.
Thanks, yannick
Your example works partially, now picture appears in the map.
For informations, the following code was the problem :
V6:
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);
With V7 we just need to remplace with :
image.Point = new DPoint(0, 0, 0);
image.Size = new DPoint(dbHeightImage, -dbHeightImage, 0);
But i still get bl1 with null after this line of code with your example when i call two times the code:
bl1 = (cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).Entities[sBlockName] as CADBlock);
I get the same problem if i test this :
CADLayer entLayer = (CADLayer)cadImage.Converter.Layers["MyLayer"];
if (entLayer == null)
{
entLayer = new CADLayer();
entLayer.Name = "MyLayer";
entLayer.Color = Color.RoyalBlue;
entLayer.Flags = 4;
entLayer.Loaded(this.cadImage.Converter);
this.cadImage.Converter.OnCreate(entLayer);
this.cadImage.CurrentLayout.AddEntity(entLayer);
}
I i call two times this code entLayer is always null after this:
CADLayer entLayer = (CADLayer)cadImage.Converter.Layers["MyLayer"];
But i didn't got this problem with V6.
Please could you explain me what is wrong.
Thanks, yannick
Re: Insert image failed with V7
Hello.
This code fragment doesn't works correctly for version 7:
use following string instead of previous:
Alexander.
This code fragment doesn't works correctly for version 7:
Code: Select all
...
this.cadImage.Converter.Blocks.Add(bl1);
...
Code: Select all
this.cadImage.Converter.GetSection(CADImport.FaceModule.ConvSection.Blocks).AddEntity(bl1);
Re: Insert image failed with V7
I thank you Alexander for yours answers. Now I manage to insert bitmap and to retrieve block and layer.
But I get a new problem with the version V7.
I manage to save a loading dwg into a dxf file with this code:
string sPathFileName = @"c:\tmp\map.dxf";
CADImport.Export.DirectCADtoDXF.CADtoDXF vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
vExp.SaveToFile(sPathFileName);
In order to verify the generated file, i use DWG TrueView 2008 from autodesk.
With version V6.3.2942.31653 the view in DWG TrueView was correct but now with version V7.2.2.21605, i don't mange to load the new generated file (dxf) in DWG True View, i get an error. I join the screen of the crash. I don't know how i can send you the original dwg.
I know that DWG True view is not your product but it seems to me that it is a software very know and use, so it's a problem if we can't use it.
Thanks, yannick.
But I get a new problem with the version V7.
I manage to save a loading dwg into a dxf file with this code:
string sPathFileName = @"c:\tmp\map.dxf";
CADImport.Export.DirectCADtoDXF.CADtoDXF vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
vExp.SaveToFile(sPathFileName);
In order to verify the generated file, i use DWG TrueView 2008 from autodesk.
With version V6.3.2942.31653 the view in DWG TrueView was correct but now with version V7.2.2.21605, i don't mange to load the new generated file (dxf) in DWG True View, i get an error. I join the screen of the crash. I don't know how i can send you the original dwg.
I know that DWG True view is not your product but it seems to me that it is a software very know and use, so it's a problem if we can't use it.
Thanks, yannick.
- Attachments
-
- crashDWGtrueview.JPG (76.73 KiB) Viewed 42715 times
Re: Insert image failed with V7
Hello.
We recently updated version of the site: http://www.cadsofttools.com/download/cadimportnet.zip. Try using it to export. Please do not pay attention to the fact that the version number has been reduced.
You can send your DWG-file at our technical support: support@cadsofttools.com
Anton
We recently updated version of the site: http://www.cadsofttools.com/download/cadimportnet.zip. Try using it to export. Please do not pay attention to the fact that the version number has been reduced.
You can send your DWG-file at our technical support: support@cadsofttools.com
Anton
Re: Insert image failed with V7
Thanks for the reply. Currently I am using the trail version to test the application. Can you suggest me in more detail, please. Because the CADText and the CADMText classes are not found in the dll file I use. I can only load the image using CADImage class. I am not sure about the namespaces for that. If possible please tell me where can I find the documentation for this.
You can join us for best HIT-001 exam dumps exam Test-king.com training solutions. Our stevenson contains all those materials you want to pass for real www.the-bac.edu exam & ase training in Principia College
Re: Insert image failed with V7
Hello,
CADImage, CADText and CADMText classes are part of CADImport namespace:
Mikhail
CADImage, CADText and CADMText classes are part of CADImport namespace:
Code: Select all
using CADImport;
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support