Printing CADImage
Moderators: SDS, support, admin
Printing CADImage
Anyone know what I need to do to set the scaling on an image so that it will print using the real world dimensions?
If a line is 3.5 inches long, I'd like the line to measure 3.5 inches long when it's printed.
If a line is 3.5 inches long, I'd like the line to measure 3.5 inches long when it's printed.
Using voloview to display a DWG file, I could programmically set the scaling and page layout information( portrait, landscape, etc )
Using CAD Import DLL I haven't figured out a way of controling the printing process.
Anyone have any ideas? The drawing is created real size, but when my box prints the dimesions are not printed in their real life size.
I'm using calipers to measure the box and the height is correct.
Printed out in Portrait mode:
My box width of 3.719 ( as created in the CAD file ) actually prints out as 3.762
In Landscape mode:
My box width of 3.719 ( as created in the CAD file ) actually prints out as 2.8475 and the height is 0.5260 instead of the actual 0.680.
I'm out of ideas and could really use a nudge or push in the right direction
Using CAD Import DLL I haven't figured out a way of controling the printing process.
Anyone have any ideas? The drawing is created real size, but when my box prints the dimesions are not printed in their real life size.
I'm using calipers to measure the box and the height is correct.
Printed out in Portrait mode:
My box width of 3.719 ( as created in the CAD file ) actually prints out as 3.762
In Landscape mode:
My box width of 3.719 ( as created in the CAD file ) actually prints out as 2.8475 and the height is 0.5260 instead of the actual 0.680.
I'm out of ideas and could really use a nudge or push in the right direction
Hello Michael,
Thank you for the question.
We will prepare respective code soon.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Thank you for the question.
We will prepare respective code soon.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Thanks for your earlier response. Your email included this code snippet:
We will prepare respective code soon.
Until that just for information it is necessary to manipulate with the following lines:
double realScaleDouble = (this.curSize.Width / this.image.AbsWidth) *
image.MMToPixelX;
double i = this.curSize.Width / realScaleDouble;
this.realSize.Width = this.curSize.Width / (this.curSize.Width / i);
this.realSize.Height = this.curSize.Height / (this.curSize.Width / i);
Can you perhaps offer more clarification? I'm basically doing a 'CADImage.Print()'.
I really need to get the scaling feature working, thanks.
We will prepare respective code soon.
Until that just for information it is necessary to manipulate with the following lines:
double realScaleDouble = (this.curSize.Width / this.image.AbsWidth) *
image.MMToPixelX;
double i = this.curSize.Width / realScaleDouble;
this.realSize.Width = this.curSize.Width / (this.curSize.Width / i);
this.realSize.Height = this.curSize.Height / (this.curSize.Width / i);
Can you perhaps offer more clarification? I'm basically doing a 'CADImage.Print()'.
I really need to get the scaling feature working, thanks.
Anyone?
This is becoming a signifigant source of frusteration.
I can adjust the CADImage on the screen to what ever size I want.
But when I call CADImage print.. it pretty much does it's own thing.
Can you please provide some sample code that will print out a CADImage with the exact size(s) that the drawing was created with?
This is becoming a signifigant source of frusteration.
I can adjust the CADImage on the screen to what ever size I want.
But when I call CADImage print.. it pretty much does it's own thing.
Can you please provide some sample code that will print out a CADImage with the exact size(s) that the drawing was created with?
Hello Michael.
Printing with keeping real sizes is a kind of new ability. Adding it to the demos requires some time and human resources. We will inform you when work on this question will be finished.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Printing with keeping real sizes is a kind of new ability. Adding it to the demos requires some time and human resources. We will inform you when work on this question will be finished.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
OK, Michael.
We will take this fact into account.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
We will take this fact into account.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Dear Michael,
The following example is made basing on <b>Viewer</b> demo available in the package CAD Import .NET (http://www.cadsofttools.com/download/cadimportnet.zip) in the ..\cadimportnet\sources\Viewer\C#\.. folder.
<ul><li>Find <font color="blue">private void</font id="blue"> <b>pd_PrintPage</b> in the module <b>PrintingForm.cs</b> and replace it by the following code:</li>
<li>Add new method into the module <b>PrintingForm.cs</b>:
</li>
<li>Build and run demo.</li>
<li>Open any CAD file.</li>
<li>Select <b>File > Custom Print Preview</b> menu item. </li></ul>
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
The following example is made basing on <b>Viewer</b> demo available in the package CAD Import .NET (http://www.cadsofttools.com/download/cadimportnet.zip) in the ..\cadimportnet\sources\Viewer\C#\.. folder.
<ul><li>Find <font color="blue">private void</font id="blue"> <b>pd_PrintPage</b> in the module <b>PrintingForm.cs</b> and replace it by the following code:
Code: Select all
<font color="blue">private void</font id="blue"> pd_PrintPage(<font color="blue">object</font id="blue"> sender, PrintPageEventArgs ev)
{
ev.Graphics.PageUnit = GraphicsUnit.Pixel;
MainForm.actForm.FCADImage.SetNewMMToPixel(ev.Graphics);
DRect curRect = <font color="blue">new</font id="blue"> DRect(0, 0, 100, 100);
curRect = SetRealSize(curRect);
Color tmpcol = MainForm.actForm.FCADImage.DefaultColor;
MainForm.actForm.FCADImage.DefaultColor = Color.Black;
MainForm.actForm.FCADImage.Draw(ev.Graphics, <font color="blue">new</font id="blue"> RectangleF(0, 0, (<font color="blue">float</font id="blue">)curRect.Width, (<font color="blue">float</font id="blue">)curRect.Height));
MainForm.actForm.FCADImage.DefaultColor = tmpcol;
}
<li>Add new method into the module <b>PrintingForm.cs</b>:
Code: Select all
<font color="blue">private</font id="blue"> DRect SetRealSize(DRect curSize)
{
DRect realSize = <font color="blue">new</font id="blue"> DRect(0, 0, 0, 0);
<font color="blue">double</font id="blue"> realScaleDouble = (curSize.Width / MainForm.actForm.FCADImage.AbsWidth) * MainForm.actForm.FCADImage.MMToPixelX;
realSize.Width = (curSize.Width / realScaleDouble);
realSize.Height = (curSize.Height / realScaleDouble);
<font color="blue">double</font id="blue"> wh = MainForm.actForm.FCADImage.AbsWidth / MainForm.actForm.FCADImage.AbsHeight;
<font color="blue">double</font id="blue"> new_wh = 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;
}
<li>Build and run demo.</li>
<li>Open any CAD file.</li>
<li>Select <b>File > Custom Print Preview</b> menu item. </li></ul>
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
<b>CAD Import .NET</b> at the following link:
http://www.cadsofttools.com/download/cadimportnet.zip contains CADImage with MMToPixelX property.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
http://www.cadsofttools.com/download/cadimportnet.zip contains CADImage with MMToPixelX property.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Hello Michael!
This code just gives an example of common logic how to supply printing 1:1. Currently we work on printing system for <b>CAD Import .NET</b>, which will have rather powerful abilities. All logic of its work will be hidden from user. He will get only some open methods for managing with printing parameters.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
This code just gives an example of common logic how to supply printing 1:1. Currently we work on printing system for <b>CAD Import .NET</b>, which will have rather powerful abilities. All logic of its work will be hidden from user. He will get only some open methods for managing with printing parameters.
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
Hello Michael!
AutoCAD allows defining how to interpret drawing units:
Set MEASUREMENT in the command line of the AutoCAD window and use the following parameters: 0 = English; 1 = Metric
Code in previous example works for files made in Metric mode.
For files made in English mode, use SetRealSize like the following:
Sergey.
Please post questions to the forum or write to support@cadsofttools.com
AutoCAD allows defining how to interpret drawing units:
Set MEASUREMENT in the command line of the AutoCAD window and use the following parameters: 0 = English; 1 = Metric
Code in previous example works for files made in Metric mode.
For files made in English mode, use SetRealSize like the following:
Code: Select all
<font color="blue">private</font id="blue"> DRect SetRealSize(DRect curSize)
{
DRect realSize = <font color="blue">new</font id="blue"> DRect(0, 0, 0, 0);
<font color="blue">double</font id="blue"> realScaleDouble = (curSize.Width / MainForm.actForm.cadImage.AbsWidth) * MainForm.actForm.cadImage.MMToPixelX / 25.4;
realSize.Width = (curSize.Width / realScaleDouble);
realSize.Height = (curSize.Height / realScaleDouble);
<font color="blue">double</font id="blue"> wh = MainForm.actForm.cadImage.AbsWidth / MainForm.actForm.cadImage.AbsHeight;
<font color="blue">double</font id="blue"> new_wh = 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;
}
Please post questions to the forum or write to support@cadsofttools.com