Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

insert all pdfs

4 REPLIES 4
Reply
Message 1 of 5
alex
1190 Views, 4 Replies

insert all pdfs

is there a way to code inserting all pdfs in a multi-page pdf at once?

 

another one would be, say, you have several pdfs in your dwg that represent different aspects of the same space so you select them (they are on top of each other) and it puts them into a dynamic block automatically in different visualization states (maybe labeled 01,02,03 etc.) and you make one of the sheets visible with a drop down button.

 

i might be able to figure out the later if there is a way to do the former.

 

any tips or suggestions on a way to do it would be appreciated.

 

thanks, alex

 

4 REPLIES 4
Message 2 of 5
dbroad
in reply to: alex

Yes, you can do it.

Here is a rough demo which creates a single row (assumes 8-1/2" wide pdfs).

;;Insert all pdf pages of a file
;;assumes single row at 8-1/2" spacing
;;Demo only
;;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 8.5))
)
(command);cancel out of index pdf underlay
(princ);quietly exit
)

 Here is a demo that can be used to change a page number of a pdf already inserted.  I would not advise putting PDF's into dynamic blocks.

;;To set a page number of the pdf file.
;;If the file disappears(page doesn't exist, use undo to get it back.
;;D. C. Broad, Jr. 2012
(defun c:setpg()
  (prompt "\nSelect PDF")
  (setq ss (ssget ":S:E" '((0 . "PDFUNDERLAY"))))
  (setq ob (vlax-ename->vla-object(ssname ss 0)))
  (initget 7)
  (vla-put-itemname ob (itoa (getint "\nNew Sheet number: ")))
  (vla-update ob)
  )

 

 

Architect, Registered NC, VA, SC, & GA.
Message 3 of 5
alex
in reply to: dbroad

thanks a lot.

Message 4 of 5
mark
in reply to: dbroad

I was working on a similar function and found your post trying to debug.  It seems that AutoCAD doesn't consider running out of pdf pages as an error, so your code stays in an endless loop once it has inserted all the pages and never exits. It continues running and considers the next value as an invalid insertion point (also apparently not considered an error by vl-catch-all-error).

Any ideas how to clue AutoCAD in to recognizing that there are no more pages in the pdf document?

Message 5 of 5
serkancavuslar
in reply to: alex

 

yes

 

AutoCAD all ver.

 

model to pdf

 

ref. pline or block

Paper Size Select

Plot Style Select

Pdf No Select

 

and run goto pdf

 

yes

 

this is possible
there is

Serkan ÇAVUŞLAR
CplCAD / Türkiye
Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost