DXF Scale

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
nico28
Posts: 5
Joined: 19 Jan 2007, 18:32
Location: France

DXF Scale

Post by nico28 » 23 Jan 2007, 14:34

Hi,

1) How can i know the scale of the current DXF File in my CADImage object ?
2) I need to know how many screen pixels are needed to draw 1 mm of my CADImage, and that in the current drawing rectangle <i>(m_FCADImage.Draw(e.Graphics, Rect)</i>


Sorry for my bad english.

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

Post by support » 26 Jan 2007, 15:51

Hello!

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">1) How can i know the scale of the current DXF File in my CADImage object ?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

By the example of Viewer demo (please find it in the ..\cadimportnet\sources\Viewer\.. folder) scaling is performed by <font size="4"><font color="blue">private float</font id="blue"> scale;</font id="size4"> parameter.

RectangleF tmp = new RectangleF(pos.X, pos.Y, curClRect.Width*scale, curClRect.Height*scale);
FCADImage.Draw(gr, tmp);
tmp - rectangle wherein CAD file is drawn. This rectangle allows scaling CAD file anyhow.
Please find respective example in the <font size="4"><font color="blue">public void</font id="blue"> DoResize()</font id="size4"> method.

[quote]2) I need to know how many screen pixels are needed to draw 1 mm of my CADImage, and that in the current drawing rectangle <i>(m_FCADImage.Draw(e.Graphics, Rect)</i>[quote]
We suggest to get coefficient of pixcels to millimeters convertion. It is necessary to use <b>Win API</b> function:

Code: Select all

<font color="blue">public abstract class</font id="blue"> GDIApi
{
          [DllImport("gdi32.dll")]
          <font color="blue">public static extern int</font id="blue"> GetDeviceCaps(IntPtr hdc, <font color="blue">int</font id="blue"> nIndex);
}

<font color="blue">public enum</font id="blue"> DeviceCap
{
          DRIVERVERSION = 0,
          TECHNOLOGY    = 2,
          HORZSIZE      = 4,
          VERTSIZE      = 6,
          HORZRES       = 8,
          VERTRES       = 10,
          BITSPIXEL     = 12,
          PLANES    = 14,
          NUMBRUSHES    = 16,
          NUMPENS       = 18,
          NUMMARKERS    = 20,
          NUMFONTS      = 22,
          NUMCOLORS     = 24,
          PDEVICESIZE   = 26,
          CURVECAPS     = 28,
          LINECAPS      = 30,
          POLYGONALCAPS = 32,
          TEXTCAPS      = 34,
          CLIPCAPS      = 36,
          RASTERCAPS    = 38,
          ASPECTX       = 40,
          ASPECTY       = 42,
          ASPECTXY      = 44,

          LOGPIXELSX    = 88,
          LOGPIXELSY    = 90,

          SIZEPALETTE  = 104,
          NUMRESERVED  = 106,
          COLORRES     = 108,

          <font color="green">// Printing related DeviceCaps. These replace the appropriate Escapes</font id="green">
          PHYSICALWIDTH   = 110,
          PHYSICALHEIGHT  = 111,
          PHYSICALOFFSETX = 112,
          PHYSICALOFFSETY = 113,
          SCALINGFACTORX  = 114,
          SCALINGFACTORY  = 115
 }
Sergey.

Please post questions to the forum or write to support@cadsofttools.com

Post Reply