“Parameter is not valid†error
Moderators: SDS, support, admin
“Parameter is not valid†error
We’ve run into a problem with CAD Import .NET (the extended version). It is giving us a “Parameter is not valid†error on some drawings. Other drawings are working fine. Here is the code that we are using. It is giving us the error on the SaveToStream line. We are using Version 1.5.2512.20425. The only thing that we've noticed that was unusual was that the .bottom returned from Extents was a negative number. On the drawings that are working, it’s a positive number.
MemoryStream ms = new MemoryStream();
dwgImage = new DWG.DWGImage();
dwgImage.LoadFromFile(dwgFile);
dwgImage.SaveToStream(ms, ImageFormat.Bmp, dwgImage.Extents);
MemoryStream ms = new MemoryStream();
dwgImage = new DWG.DWGImage();
dwgImage.LoadFromFile(dwgFile);
dwgImage.SaveToStream(ms, ImageFormat.Bmp, dwgImage.Extents);
Hello!
Last version of <b>CAD Import .NET</b> is dated by Fabruary, 2007. DLL version is 6.0.2645.16081.
We recommend to use the following code, which is based on Viewer demo:
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">The only thing that we've noticed that was unusual was that the .bottom returned from Extents was a negative number.<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
This is normal situation because of coordinates on the drawing may have negative X, Y znd Z. Thus Extents returns a box with negative points.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Last version of <b>CAD Import .NET</b> is dated by Fabruary, 2007. DLL version is 6.0.2645.16081.
We recommend to use the following code, which is based on Viewer demo:
Code: Select all
<font color="blue">private void</font id="blue"> btnReadStream_Click(<font color="blue">object</font id="blue"> sender, System.EventArgs e)
{
MemoryStream ms = <font color="blue">new</font id="blue"> MemoryStream();
DWG.DWGImage dwgImage = <font color="blue">new</font id="blue"> DWG.DWGImage();
dwgImage.LoadFromFile(@"c:\Test.dwg");
Graphics gr = <font color="blue">this</font id="blue">.cadPictBox.CreateGraphics();
dwgImage.SaveToStream(ms, ImageFormat.Bmp, SetRealSize(dwgImage, gr));
}
<font color="blue">private</font id="blue"> CADImport.DRect SetRealSize(CADImage img, Graphics gr)
{
CADImport.DRect realSize = <font color="blue">new</font id="blue"> CADImport.DRect(0, 0, 1, 1);
img.SetNewMMToPixel(gr);
<font color="blue">float</font id="blue"> realScaleDouble = (<font color="blue">float</font id="blue">)(realSize.Width / img.AbsWidth * img.MMToPixelX / 25.4);
realSize.Width = (realSize.Width / realScaleDouble);
realSize.Height = (realSize.Height / realScaleDouble);
<font color="blue">float</font id="blue"> wh = (<font color="blue">float</font id="blue">)(img.AbsWidth / img.AbsHeight);
<font color="blue">float</font id="blue"> new_wh = (<font color="blue">float</font id="blue">)(realSize.Width / realSize.Height);
<font color="blue">if</font id="blue">(new_wh > wh)
realSize.Width = realSize.Height * wh;
<font color="blue">else</font id="blue">
{
<font color="blue">if</font id="blue">(new_wh < wh)
{
realSize.Height = realSize.Width / wh;
}
}
<font color="blue">return</font id="blue"> realSize;
}
This is normal situation because of coordinates on the drawing may have negative X, Y znd Z. Thus Extents returns a box with negative points.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com