Jump to content
JoeyG_77

PDF insert

Recommended Posts

JoeyG_77

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
)

 

Share this post


Link to post
Share on other sites
Roy_043

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)
)

 

Share this post


Link to post
Share on other sites
JoeyG_77

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

Share this post


Link to post
Share on other sites
Roy_043

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.

Share this post


Link to post
Share on other sites
BIGAL

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 by BIGAL

Share this post


Link to post
Share on other sites
Roy_043

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)
)

 

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...