Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9733 > unrolled thread

Controlling scale of Graphics on paper

Started byJoseph Gwinn <joegwinn@comcast.net>
First post2012-04-21 04:32 +0000
Last post2012-04-29 06:14 +0000
Articles 6 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Controlling scale of Graphics on paper Joseph Gwinn <joegwinn@comcast.net> - 2012-04-21 04:32 +0000
    Re: Controlling scale of Graphics on paper Yves Klett <yves.klett@googlemail.com> - 2012-04-23 09:43 +0000
      Re: Controlling scale of Graphics on paper Yves Klett <yves.klett@googlemail.com> - 2012-04-24 09:32 +0000
        Re: Controlling scale of Graphics on paper Joseph Gwinn <joegwinn@comcast.net> - 2012-04-26 09:27 +0000
    Re: Controlling scale of Graphics on paper Szabolcs Horvát <szhorvat@gmail.com> - 2012-04-27 10:52 +0000
      Re: Controlling scale of Graphics on paper Joseph Gwinn <joegwinn@comcast.net> - 2012-04-29 06:14 +0000

#9733 — Controlling scale of Graphics on paper

FromJoseph Gwinn <joegwinn@comcast.net>
Date2012-04-21 04:32 +0000
SubjectControlling scale of Graphics on paper
Message-ID<jmtd9i$sim$1@smc.vnet.net>
I would like to use Mathematica to make printed templates of various 
kinds.  

In one use, a complicated shape is generated mathematically and 
displayed using Graphics or Show, the plot is printed on paper, the 
paper is glued to a piece of wood, which is cut and drilled to the lines 
and center-points.  This requires the ability to control the on-paper 
scale factor, so that a length of 1.0 in a line ends up being one inch 
(or one centimeter) on paper.  

I assume that this is possible, but have not found anything relevant in 
the online documentation.  What I have done is used Mathematica to make 
dolls of machine parts; in this case it was sufficient that all be in 
the same scale, which was achieved using ImageSize->72*6 directives, but 
ImageSize doesn't speak directly to the issue of scale on paper.

It may be that ImageSize->{w,h} can be used, but there is some math 
required.

So, my question is how best to achieve a specified scale on paper.  

TIA,

Joe Gwinn

[toc] | [next] | [standalone]


#9758

FromYves Klett <yves.klett@googlemail.com>
Date2012-04-23 09:43 +0000
Message-ID<jn388q$g83$1@smc.vnet.net>
In reply to#9733
No guarantuees, but I used something like:

ExportScaled[filename_,gfx_,format_:{210,297},opts___?OptionQ]:=Module[{mm},
mm=72/25.4;
Export[filename,Show[gfx,ImageSize->format*mm,ImageMargins->0,ImagePadding->None,AspectRatio->Automatic],opts]
]


with good success together with PDF and EPS export formats (i.e.
filenames of the "xxx.pdf" kind). Note that the scaling factor is set to
generate 1mm units. The default "format" is set to Din A4.

Regards,
Yves



Am 21.04.2012 06:32, schrieb Joseph Gwinn:
> I would like to use Mathematica to make printed templates of various 
> kinds.  
> 
> In one use, a complicated shape is generated mathematically and 
> displayed using Graphics or Show, the plot is printed on paper, the 
> paper is glued to a piece of wood, which is cut and drilled to the lines 
> and center-points.  This requires the ability to control the on-paper 
> scale factor, so that a length of 1.0 in a line ends up being one inch 
> (or one centimeter) on paper.  
> 
> I assume that this is possible, but have not found anything relevant in 
> the online documentation.  What I have done is used Mathematica to make 
> dolls of machine parts; in this case it was sufficient that all be in 
> the same scale, which was achieved using ImageSize->72*6 directives, but 
> ImageSize doesn't speak directly to the issue of scale on paper.
> 
> It may be that ImageSize->{w,h} can be used, but there is some math 
> required.
> 
> So, my question is how best to achieve a specified scale on paper.  
> 
> TIA,
> 
> Joe Gwinn
> 

[toc] | [prev] | [next] | [standalone]


#9771

FromYves Klett <yves.klett@googlemail.com>
Date2012-04-24 09:32 +0000
Message-ID<jn5rum$nr4$1@smc.vnet.net>
In reply to#9758
Addendum to my first post:

This does only work properly if the PlotRange of the graphics object is
set to reflect the values of "format" (had not used that one in a while).

So making sure your dimensions are correct by using ghostview is always
a good idea ;-)

So the right way to use this is:

gfx = Graphics[Line[{{10, 10}, {110, 10}, {110, 110}}],
  PlotRange -> {{0, 200}, {0, 200}}]

ExportScaled[filename_, gfx_, format_: {210, 297}, opts___?OptionQ] :=
  Module[{mm}, mm = 72/25.4;
  Export[filename,
   Show[gfx, ImageSize -> format*mm, ImageMargins -> 0,
    ImagePadding -> None, AspectRatio -> Automatic], opts]]

ExportScaled["test.eps", gfx, -Subtract @@@ (PlotRange /.
     Options[gfx, PlotRange])]

It is a good idea to set the PlotRange values for your graphics object
*explicitely*, because extracting the with FullOptions can result in
added whitespace (at least in some cases).

Regards,
Yves



Am 23.04.2012 11:43, schrieb Yves Klett:
> ExportScaled[filename_,gfx_,format_:{210,297},opts___?OptionQ]:=Module[{mm},
> mm=72/25.4;
> Export[filename,Show[gfx,ImageSize->format*mm,ImageMargins->0,ImagePadding->None,AspectRatio->Automatic],opts]
> ]

[toc] | [prev] | [next] | [standalone]


#9795

FromJoseph Gwinn <joegwinn@comcast.net>
Date2012-04-26 09:27 +0000
Message-ID<jnb4dh$5d5$1@smc.vnet.net>
In reply to#9771
In article <jn5rum$nr4$1@smc.vnet.net>,
 Yves Klett <yves.klett@googlemail.com> wrote:

> Addendum to my first post:
> 
> This does only work properly if the PlotRange of the graphics object is
> set to reflect the values of "format" (had not used that one in a while).
> 
> So making sure your dimensions are correct by using ghostview is always
> a good idea ;-)
> 
> So the right way to use this is:
> 
> gfx = Graphics[Line[{{10, 10}, {110, 10}, {110, 110}}],
>   PlotRange -> {{0, 200}, {0, 200}}]
> 
> ExportScaled[filename_, gfx_, format_: {210, 297}, opts___?OptionQ] :=
>   Module[{mm}, mm = 72/25.4;
>   Export[filename,
>    Show[gfx, ImageSize -> format*mm, ImageMargins -> 0,
>     ImagePadding -> None, AspectRatio -> Automatic], opts]]
> 
> ExportScaled["test.eps", gfx, -Subtract @@@ (PlotRange /.
>      Options[gfx, PlotRange])]
> 
> It is a good idea to set the PlotRange values for your graphics object
> *explicitly*, because extracting the with FullOptions can result in
> added whitespace (at least in some cases).

So, it is necessary to set five things in a self-consistent manner to 
achieve the desired scale control.  I had guessed that three things were 
needed.

I'll be trying this.

Thanks,

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#9830

FromSzabolcs Horvát <szhorvat@gmail.com>
Date2012-04-27 10:52 +0000
Message-ID<jndtpo$jm0$1@smc.vnet.net>
In reply to#9733
On 2012.04.21. 6:32, Joseph Gwinn wrote:
> I would like to use Mathematica to make printed templates of various
> kinds.
>
> In one use, a complicated shape is generated mathematically and
> displayed using Graphics or Show, the plot is printed on paper, the
> paper is glued to a piece of wood, which is cut and drilled to the lines
> and center-points.  This requires the ability to control the on-paper
> scale factor, so that a length of 1.0 in a line ends up being one inch
> (or one centimeter) on paper.
>
> I assume that this is possible, but have not found anything relevant in
> the online documentation.  What I have done is used Mathematica to make
> dolls of machine parts; in this case it was sufficient that all be in
> the same scale, which was achieved using ImageSize->72*6 directives, but
> ImageSize doesn't speak directly to the issue of scale on paper.
>
> It may be that ImageSize->{w,h} can be used, but there is some math
> required.
>
> So, my question is how best to achieve a specified scale on paper.
>

You got several suggestions.  One thing that hasn't been mentioned yet 
is exporting to DXF.

DXF is a CAD-specific format, so there's support for printing to exact 
scales.  First export to DXF, then open it with a CAD program or a DXF 
viewer and print to a precise scale.  I think this will fit your 
application best.

If you are going to go the PDF route, this might be valuable (similar to 
other suggestions):

http://mathematica.stackexchange.com/a/750/12

You'll need to get rid of any PlotRangePadding and ImageMargins too, if 
you choose this route.


-- 
Szabolcs Horvát
Visit Mathematica.SE:  http://mathematica.stackexchange.com/

[toc] | [prev] | [next] | [standalone]


#9872

FromJoseph Gwinn <joegwinn@comcast.net>
Date2012-04-29 06:14 +0000
Message-ID<jnim7m$aml$1@smc.vnet.net>
In reply to#9830
In article <jndtpo$jm0$1@smc.vnet.net>,
 Szabolcs Horvát <szhorvat@gmail.com> wrote:

> On 2012.04.21. 6:32, Joseph Gwinn wrote:
> > I would like to use Mathematica to make printed templates of various
> > kinds.
> >
> > In one use, a complicated shape is generated mathematically and
> > displayed using Graphics or Show, the plot is printed on paper, the
> > paper is glued to a piece of wood, which is cut and drilled to the lines
> > and center-points.  This requires the ability to control the on-paper
> > scale factor, so that a length of 1.0 in a line ends up being one inch
> > (or one centimeter) on paper.
> >
> > I assume that this is possible, but have not found anything relevant in
> > the online documentation.  What I have done is used Mathematica to make
> > dolls of machine parts; in this case it was sufficient that all be in
> > the same scale, which was achieved using ImageSize->72*6 directives, but
> > ImageSize doesn't speak directly to the issue of scale on paper.
> >
> > It may be that ImageSize->{w,h} can be used, but there is some math
> > required.
> >
> > So, my question is how best to achieve a specified scale on paper.
> >
> 
> You got several suggestions.  One thing that hasn't been mentioned yet 
> is exporting to DXF.
> 
> DXF is a CAD-specific format, so there's support for printing to exact 
> scales.  First export to DXF, then open it with a CAD program or a DXF 
> viewer and print to a precise scale.  I think this will fit your 
> application best.
> 
> If you are going to go the PDF route, this might be valuable (similar to 
> other suggestions):
> 
> http://mathematica.stackexchange.com/a/750/12
> 
> You'll need to get rid of any PlotRangePadding and ImageMargins too, if 
> you choose this route.

Hmm.  I do have a CAD program (Alibre), and it does understand DXF (of 
course), but that's a whole new world.  

I was hoping for a simpler solution, in Mathematica only, for 
non-precision and one-off applications.  One would hope and assume that 
Mathematica can do this natively.

But it's a good idea nonetheless, for more complex jobs.

Joe Gwinn

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web