Postscript page size: plywood sheet for CNC routing.

Started by TedWalther, August 08, 2017, 02:11:20 PM

Previous topic - Next topic

TedWalther

I'm using newlisp to make postscript (and thus, PDF) files for cutting things on laser cutters and CNC machines.  I love the ability to be precise and exact in my lines and angles.



For CNC cutting, I want to use plywood pieces bigger than a typical sheet of paper.  Lots of CNC software accepts PDF files where the page size is 4 feet by 8 feet, the same size as a typical sheet of plywood.



How can I specify page size using the postscript module?  If I knew how to edit the raw postscript by hand, I'd submit an updated version of postscript.lsp myself, so if someone knows how to do that in raw postscript, please post here.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

TedWalther

#1
This page may have the info I need.  I'll do some experiments.



http://pages.cs.wisc.edu/~rjl/landscape/">http://pages.cs.wisc.edu/~rjl/landscape/
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#2
You can convert a postscript file to a pdf file using the ghostscript utility 'gs' (unix). The command lets you specify the points per inch and resolution and size of the pdf file in points. I use the following to convert ps files to pdf files for printing 8.25 by 11 inch paper images:



gs -sDEVICE=pdfwrite -q -o$1.pdf -r300 -g2475x3300 $1.ps


This is a batch file $1 is the filename parameter.



2475 / 300 = 8.25   ; leave 0.25 inch to left for binding

3300 / 300 = 11



In the printer program I can specify the 300 points/inch print resolution.



In my .ps generating .lsp scripts I use the 'ps:canvas' command to specify the point size of the image e.g. for a 8.5 by 11 inch computer screen image with 72 points per inch I specify '(ps:canvas "myCanvas" 792 612)' for landscape output.



This way I can easily design and review on a computer screen, then print in any size and resolution using a printer.



See also here: https://www.ghostscript.com/">https://www.ghostscript.com/

TedWalther

#3
Thanks Lutz.  I found I can do it entirely in the Postscript.  I took the postscript output by newlisp, and edited it by hand.  Here is the diff; it just needed 3 lines added, and 1 line modified.



-%!PS-Adobe-2.0
+%!PS-Adobe-3.0
 %%Creator: newLISP
+%%Orientation: Portrait
+%%DocumentMedia: plywood 6912 3456 80 () ()
 
 %% ---------- SETUP ----------
 
+<< /PageSize [6912 3456] >> setpagedevice
 /orient 0 def
 /xpos 0 def
 /ypos 0 def


I totally did not see a ps:canvas command in the documentation for the postscript module.  Is it undocumented?  It looks like a good place to set page size; and maybe orientation too.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#4
Oops, there is no 'ps:canvas' only a 'cv:canvas' in the canvas.lsp module. I use the following code in all of my http://www.newlisp.org/art/">http://www.newlisp.org/art/ drawings to create either .html or .ps output with the same code. The '(set 'ps cv)' statement makes the postscript code work with the canvas.lsp module.



#!/usr/local/bin/newlisp

(set-locale "C")
(if (= (main-args -1) "ps")
    (load "postscript.lsp")
    (load "canvas.lsp")
)

(if (context? ps)
    (begin
        (ps:font "Helvetica" 15)
        (ps:angle 0)
        (set 'render-file "tools.ps")
        ; for horizontal landscape layout
        ;(ps:rotate -90)        ; 11 x 8.5, horizontal layout
        ;(ps:translate -792 0)  ; 11 x 8.5, horizontal layout
    )
    (begin ; canvas
        (set 'ps cv)
        (ps:canvas "myCanvas" 612 792) ; portrait layout
        ;(ps:canvas "myCanvas" 792 612) ; landscape layout
        (ps:font "15px sans-serif")
        (set 'render-file "tools.html")
    )
)


By default it uses canvas.lsp and generates a .html file, but when adding the 'ps' parameter to the command line it generates .ps files.



Orientation gets changed using ps:rotate and ps:translate. The print size then gets changed when using .pdf files and using the Ghostscript command 'gs' as shown in the previous post.



Print device dependent settings should be added manually to the postscript.lsp file, the way you are doing it in the 'prolog' section starting line 493.