Jump to content

PDF insert


JoeyG_77

Recommended Posts

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
)

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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