JoeyG_77 Posted December 2, 2019 Posted December 2, 2019 Hey Guys ... I found this older lisp & it works great, but it doesn't stop once all the pages are inserted. I can make mods to code but writing new parts and inserting them isnt my bag. Please take a look and just insert a stop once all the pages are inserted. Thanks Joe PS Thanks for D.C. Broad, Jr. for the original code back in 2012 ;;Insert all pdf pages of a file ;;D.C. Broad, Jr. 2012 ;;Warning: Once started, cannot be escaped from till done. (defun c:atall (/ fn n pt) (setq fn (getfiled "Select PDF File" "" "pdf" 8)) (setq n 1) (setq pt '(0.0 0.0 0.0));;prompt for insertion point here (while (not (vl-catch-all-error-p ;avoid error trigger (vl-catch-all-apply '(lambda () (command "-pdfattach" fn (itoa n) pt 1 0) ) nil ) ) ) (setq n (1+ n)) (setq pt (polar pt 0.0 1000)) ) (command);cancel out of index pdf underlay (princ);quietly exit ) Quote
Roy_043 Posted December 3, 2019 Posted December 3, 2019 Try this: (defun c:atall (/ fn n pre pt) (setq fn (getfiled "Select PDF File" "" "pdf" 8)) (setq n 1) (setq pt '(0.0 0.0 0.0)) (setvar 'cmdecho 0) (while (and (not (command "_.-pdfattach" fn n pt 1 0)) (not (equal pre (setq pre (entlast)))) ) (setq n (1+ n)) (setq pt (polar pt 0.0 1000)) ) (setvar 'cmdecho 1) (princ) ) Quote
JoeyG_77 Posted December 3, 2019 Author Posted December 3, 2019 Roy, Thanks it did work but when the last one is inserted its like it hit enter and wants to insert another pdf. i have to hit esc to cancel the command. It did work much better but is there a way to get a clear command line at the end ? Thanks Joe Quote
Roy_043 Posted December 3, 2019 Posted December 3, 2019 I am using BricsCAD V18. The code ends properly in that program. But there is a message in the command line: : ATALL ERROR: PDF Underlay page not found. I'll try to investigate. Quote
BIGAL Posted December 3, 2019 Posted December 3, 2019 (edited) I think it was Lee that had a how many pages in a pdf solution. Then use repeat. www.theswamp.org/index.php?topic=39001.msg441632#msg441632 Edited December 3, 2019 by BIGAL Quote
Roy_043 Posted December 4, 2019 Posted December 4, 2019 Thanks for the link BIGAL. I didn't know you could do that. Here is a solution without getting the number of pages from the PDF: (defun c:atall (/ fn n pre pt) (setq fn (getfiled "Select PDF File" "" "pdf" 8)) (setq n 1) (setq pt '(0.0 0.0 0.0)) (setvar 'cmdecho 0) (while (and (not (command "_.-pdfattach" fn n pt 1 0)) (progn (while (> (getvar 'cmdactive) 0) (command nil) ; You may have to remove nil. ) T ) (not (equal pre (setq pre (entlast)))) ) (setq n (1+ n)) (setq pt (polar pt 0.0 1000)) ) (setvar 'cmdecho 1) (princ "\r") ; Remove last prompt. (princ) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.