Postscript page size: plywood sheet for CNC routing.

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Postscript page size: plywood sheet for CNC routing.

Post by 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
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: Postscript page size: plywood sheet for CNC routing.

Post by TedWalther »

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

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Postscript page size: plywood sheet for CNC routing.

Post by Lutz »

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:

Code: Select all

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/

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: Postscript page size: plywood sheet for CNC routing.

Post by TedWalther »

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.

Code: Select all

-%!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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: Postscript page size: plywood sheet for CNC routing.

Post by Lutz »

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

Code: Select all

#!/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.

Tatiana_Sn
Posts: 3
Joined: Mon Aug 19, 2019 9:03 am
Location: Russian
Contact:

-

Post by Tatiana_Sn »

No, you can assign an id only for trophy you should change the whole competition and grapich stuff, but competitions that dont have a self trophy uses trophy_0


Life is Beautiful

Locked