PLOT all tabs using LISP (Not Using PUBLISH)

PLOT all tabs using LISP (Not Using PUBLISH)

Anonymous
Not applicable
1,696 Views
4 Replies
Message 1 of 5

PLOT all tabs using LISP (Not Using PUBLISH)

Anonymous
Not applicable

Hello Everyone,

 

I have a LISP function that currently plots my "Model" tab using the PLOT function. I have the function run in the background without any user intervention after a user clicks a shortcut in AutoCAD. A PDF of the "Model" tab is automatically saved to my selected default directory.

 

My goal is to print not just my "Model" tab but all of the tabs in the particular DWG file. Sometimes the other tabs are named "Layout", "Revision", as well as others. I would like to have all these tabs saved onto ONE PDF file.

 

I know the PUBLISH command performs a similar function but that requires a manual setup by the user and I want to avoid that at all costs which is why I use the PLOT function shown below.

 

Help would be greatly appreciated.

(defun C:PDFSave (/ filename)

  	(vl-load-com)
	(princ "\n Saving PDF of floor plan... ")
	(princ "\n")
	(setvar "cmdecho" 0)
  

  	;;Set file save location
	(setenv "PlotToFilePath" "X")
	(setenv "PlotToFilePath" "Y")
	(setq filename (vl-filename-base (getvar 'dwgname)))
	(setq filename (strcat "X\\" (vl-filename-base (getvar 'dwgname)) ".pdf"))
	

	;;Start Plotting
	(command "-plot"  ; Start plot command
	"y" ; Detailed plot configuration? 
	"Model"  ; Get current layout name
	"DWG to PDF.pc3"  ; Enter an output device name
	"ARCH full bleed D (24.00 X 36.00 Inches)" ; Enter paper size
	"Inches" ; Enter paper units
	"Landscape"  ; Enter drawing orientation
	"No"	; Plot upside down?
	"Extents" ; Enter plot area
	"Fit" ; Enter plot scale
	"Center" ; Enter plot offset (x,y)
	"Yes"  ; Plot with plot styles?
	"." ; Enter plot style table name or
	"No"  ; Plot with lineweights?
	"As Displayed" ;Enter shade plot setting
	filename	
	"No" ; Save changes to page setup
	"Yes" ; Proceed with plot	
	)

	(princ "\n PDF Save Successfully Completed!. ")
	(setvar "cmdecho" 1)
  	(princ)		
	
)
0 Likes
1,697 Views
4 Replies
Replies (4)
Message 2 of 5

Jonathan3891
Advisor
Advisor

Something like this should do the trick

 

  ;;Start Plotting
	(foreach layoutname (layoutlist)
	(command ".layout" "set" layoutname)
	(command "-plot"  ; Start plot command
	"y" ; Detailed plot configuration? 
	Layoutname ; Get current layout name
	"DWG to PDF.pc3"  ; Enter an output device name
	"ARCH full bleed D (24.00 X 36.00 Inches)" ; Enter paper size
	"Inches" ; Enter paper units
	"Landscape"  ; Enter drawing orientation
	"No"	; Plot upside down?
	"Extents" ; Enter plot area
	"Fit" ; Enter plot scale
	"Center" ; Enter plot offset (x,y)
	"Yes"  ; Plot with plot styles?
	"." ; Enter plot style table name or
	"No"  ; Plot with lineweights?
	"As Displayed" ;Enter shade plot setting
	filename	
	"No" ; Save changes to page setup
	"Yes" ; Proceed with plot	
	)
	)
  (princ)
  )

Jonathan Norton
Blog | Linkedin
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for the quick response!

I receive the following error when attempting to use the revised code:

 

Command: PDFSave
 Saving PDF of floor plan...
 Finished setting file save directory...
 Assigning filename to plot... Unknown command 
"directory\Y.PDF".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "YES".  Press F1 for help.
 Assigning filename to plot... Unknown command 
"directory\Y.PDF".  Press F1 for help.
Unknown command "NO".  Press F1 for help.
Unknown command "YES".  Press F1 for help.
 PDF Save Successfully Completed!.

I added some princ statements to see where the code was having issues and it looks like the filename is not being accepted.  Could there be a new prompt after "As Displayed" and before the filename is to be entered?

 

 

 

(defun C:PDFSave (/ filename)

  	(vl-load-com)
	(princ "\n Saving PDF of floor plan... ")
	(princ "\n")
	(setvar "cmdecho" 0)
  

  	;;Set file save location
	(setenv "PlotToFilePath" "directory")
	(setq filename Y)
	(setq filename (strcat "directory\\" Y ".pdf"))
	
	(princ "\n Finished setting file save directory... ")

	;;Start Plotting
	(foreach layoutname (layoutlist)
	(command ".layout" "set" layoutname)
	(command "-plot"  ; Start plot command
	"y" ; Detailed plot configuration? 
	Layoutname  ; Get current layout name
	"DWG to PDF.pc3"  ; Enter an output device name
	"ARCH full bleed D (24.00 X 36.00 Inches)" ; Enter paper size
	"Inches" ; Enter paper units
	"Landscape"  ; Enter drawing orientation
	"No"	; Plot upside down?
	"Extents" ; Enter plot area
	"Fit" ; Enter plot scale
	"Center" ; Enter plot offset (x,y)
	"Yes"  ; Plot with plot styles?
	"." ; Enter plot style table name or
	"No"  ; Plot with lineweights?
	"As Displayed" ;Enter shade plot setting
	(princ "\n Assigning filename to plot... ")
	filename	
	"No" ; Save changes to page setup
	"Yes" ; Proceed with plot	
	)
	)

	(princ "\n PDF Save Successfully Completed!. ")
	(setvar "cmdecho" 1)
	(princ)		
	
)

 

 

0 Likes
Message 4 of 5

Jonathan3891
Advisor
Advisor

You're missing some plot options.

 

You can see all the options from this set of working code here;

 

(defun 11x17 ( / )
  (foreach layoutname (vl-remove "model" (layoutlist))
    (command ".layout" "set" layoutname)
    (command "-plot"
	     "yes"
	     layoutname
	     "default windows system printer.pc3" ;Printer Name
	     "11\" x 17\""  ;Paper Size
	     "Inches" ;Paper Units
	     "Landscape" ;Orientation
	     "No" ;Plot Upside Down?
	     "Extents" ;Plot Area
	     "Fit" ;Plot Scale
	     "Center" ;Plot Offset
	     "Yes" ;Use Plot Style?
	     "17x11.ctb" ;Plot Style Name
	     "Yes" ;Plot Lineweights?
	     "No" ;Scale Lineweights?
	     "No" ;Paper Space First?
	     "No" ;Hide Paper Space?
	     "No" ;Plot to File?
	     "No" ;Save Page Setup?
	     "Yes" ;Continue to Plot?
	     )
	     )
    (princ)
    )

 


Jonathan Norton
Blog | Linkedin
0 Likes
Message 5 of 5

maratovich
Advisor
Advisor

Maybe this will help you: Revers - Automatic batch printing a multiple format (rectangles, frames) of model space and layouts....

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes