Printing CADImage

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Printing CADImage

Post by michael » 28 Mar 2007, 23:42

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.

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 30 Mar 2007, 01:49

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

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

Post by support » 30 Mar 2007, 16:30

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

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 12 Apr 2007, 01:15

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.

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 14 Apr 2007, 00:20

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?

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

Post by support » 16 Apr 2007, 13:38

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

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 16 Apr 2007, 17:32

Thank you!

We recently purchased a 1000 user license and this functionality, the printing of a drawing in real size is one of the most important needs we have.

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

Post by support » 16 Apr 2007, 19:31

OK, Michael.

We will take this fact into account.

Sergey.

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

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

Post by support » 24 Apr 2007, 17:30

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:

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>
<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>
<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

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 24 Apr 2007, 17:59

Thank you!

I'll give that a try right now.

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 24 Apr 2007, 18:08

One problem, CADImage doesn't have a MMToPixelX property

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

Post by support » 24 Apr 2007, 18:28

<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

michael
Posts: 13
Joined: 28 Mar 2007, 23:37
Location: USA

Post by michael » 26 Apr 2007, 00:38

Sergey:

With this code I get an image about 1" high when run the viewer demo and select the FILE | Custom Print Preview option.

Any suggestions on what I may be doing wrong?

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

Post by support » 26 Apr 2007, 09:03

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

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

Post by support » 26 Apr 2007, 09:52

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:

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;
}
Sergey.

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

Post Reply