[PythonCAD] printing

Eric Wilhelm ewilhelm at sbcglobal.net
Sat Jul 10 07:05:05 CEST 2004

# The following was supposedly scribed by
# Art Haas
# on Friday 02 July 2004 03:21 pm:

>> I'm not particularly fond of autocad's multi-layout-tabs and its habit of
>> storing all of your layouts in the same file with your model.  Since
>> pythoncad is 2D, it is essentially pure paperspace.  So, rather than
>> constructing a whole new interface for paperspace, just add some
>> paper-centric functionality to pythoncad and have your drafting space be
>> your paper space.  Then, you save layouts just like other files.  Give
>> them a second extension if you like, just to indicate that they are ready
>> for batch plotting.
>My lack of AutoCAD experience is exposed as I don't know just what that
>program is doing. The peper-space stuff sounds familiar due to writing
>the DXF/DWG reading code.

Well,  AutoCAD uses a 'model space' and 'paper space' concept.  That is, the 
model is a drawing at real-world dimensions and the layout is on a sheet of 
paper (with real paper-size dimensions.)

The way it (and others including catia and pro-e (can anyone say about 
microstation?)) handles displaying the model in paper space is that you 
create 'viewports'.  So, if you had a 3D model, you could create a layout 
with 4 viewports (and you can clip these viewports, rotate the view, set the 
scale for each one, etc,etc)  If you only have a 2D drawing this can still be 
useful to show e.g. details or even just to re-arrange the drawing layout 
without changing the model-view content/positioning.  Freezing layers can 
also be done on a per-viewport basis.

My suggestion here is that rather than trying to replicate the paperspace 
functions and creating a viewport entity (which only exists in paperspace) 
that  you simply make block or xref-like entities which behave like 

I think there is a lot of discontinuity (for the programmer and the user) with 
AutoCAD's model of paper-space.  Particularly when you are dealing with a 
2D-only cad application.  With 3D modelers like Catia and Pro-E it is quite 
different (here, paperspace is a necessary thing and drafted representations 
of models are different than the models.)

So, consider this:  I draw three views of my project in pythoncad, and save 
this as project.xml.gz.  In this file, I've got multiple layers defined (I'll 
creatively call them 1 and 2.)  Now,  I create a new pythoncad drawing (maybe 
starting from a template for 24x36 paper) and I instantiate project.xml.gz 
twice (positioning two of my three views with layer 1 active) and then add my 
title-block and etc.  I'll save this as sheet1.xml.gz and go on to create 
another 24x36 layout with view 2 & 3 and layer 2 active.  This, I'll save as 

For all practical purposes, sheet1.xml.gz and sheet2.xml.gz are now equivalent 
to (layouts) printouts of my drawing (with everything as it should be, 
layers, scales, and etc.)  Maybe I print them now, or maybe I go back into 
project.xml.gz and make some changes.  Regardless, when I'm ready to print, I 
should not have to revisit my layouts (since I maybe created 5 or 6 of them 
to print on various sizes of paper.)

Given this scheme, here's how we batch plot:

(where pycad2ps just draws in postscript format exactly what pythoncad would 
display on-screen)

for i in 1 2 ;do pycad2ps -c sheet$i.xml.gz |lp -P24x36plotter ;done

Printing from inside of pythoncad should essentially perform the same 
operation, which means that print and export are equivalent except that 
'print' means 'send a postscript export format to this printer'.

"Texas is the place where there are the most cows and the least 
milk and the most rivers and the least water in them, and where 
you can look the farthest and see the least."
                                        --H. L. Mencken

More information about the PythonCAD mailing list