Jump to content

MULTIPLOT PDF MODELSPACE


jim78b

Recommended Posts

https://m.blog.naver.com/iagapeu/221322734578

 

If you have no problems using the translator, I tested that the lsp file (in zip file) in the following link works

 

First, create a folder named "pdf" on the c drive. (c:\pdf\)

If you set the plotter name, ctb, and paper name correctly in lisp code.

(example) 

plotter name DWG to PDF.pc5
paper name ISO full bleed A1 (841.00 x 594.00 MM)
ctb name : Monochrome.ctb

Modify it to suit your environment

and set pppscaleonfit variable to "fit". it is possible to print a0, a1 also.

 

The command is pdf, and it is executed when all blocks to be output are selected. This is an lsp file, so you can know how it works.

ppp_pdf.lsp

Edited by exceed
  • Thanks 1
Link to comment
Share on other sites

18 hours ago, jim78b said:

not like you said it in a contemptuous tone

Not sure where you are getting that but ... here's an untested start for your model space printing. You will need to fill in the correct print parameters for your setup.

(defun c:foo (/ s p1 p2)
  (if (setq s (ssget '((0 . "INSERT") (2 . "A2_"))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (vla-getboundingbox (vlax-ename->vla-object e) 'p1 'p2)
      (mapcar 'set '(p1 p2) (mapcar 'vlax-safearray->list (list p1 p2)))
      (command "-plot"	    "yes"	 ""	      "DWG To PDF.pc3" ;Printer Name
	       "11\" x 17\""		;Paper Size
	       "Millimeters"		;Paper Units
	       "Landscape"		;Orientation
	       "No"			;Plot Upside Down
	       "Window"			;Plot Area
	       p1	    p2
	       "1" ;Plot Scale
	       "Center"			;Plot Offset
	       "Yes"			;Use Plot Style
	       "yourcolortable.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)
)

 

Definitely look into paperspace and sheet sets .. they are a great tool for printing.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

11 hours ago, Steven P said:

Might be that someone has a LISP that will create layouts and viewports based on you clicking the corners of your model space layouts. I don't but it is the type of thing someone might have seen somewhere.

Of course have.
But if the author says that pressing two buttons is a lot of work, then I think that this will not help him.

  • Like 1
  • Funny 1
Link to comment
Share on other sites

(defun c:pdf( / activelayout ctbname pdgsccpaper pdgsccpapera4 P_plotername P_papername PATH PDFdelay pppscaleonfit pltovrd mmmvorder mmmvhide *error* ent pwgs ss1 ppw1 ppw2 vpw1 vpw2 pwwsel pdgscc1 pdgscc pdgscc4 wlp) 
  (vl-load-com) ;activate vl code
  (setq pdgsccpaper 514.4016); a3 paper length, if pppscaleonfit is "FIT", this lisp is not use this variable
  (setq pdgsccpapera4 363.7430); a4 paper length, if pppscaleonfit is "FIT", this lisp is not use this variable

  (setq activelayout (vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object)))) ;get active layout for get batch plot settings
 
  (setq p_plotername (vl-string-translate "_" " " (vla-get-ConfigName activelayout))) ;get plotter name
  (setq p_papername (vl-string-translate "_" " " (vla-get-CanonicalMediaName activelayout))) ;get paper name
  (setq ctbname (vla-get-StyleSheet activelayout)) ;get ctb name
 
  (setq path (getvar "dwgprefix")) ;get dwg file's folder
  (setq PDFdelay 3000) ;for make sure spooling pdf. 

  (setq answer (getstring (strcat "\n\n Plotter - " P_plotername " / Paper - " P_papername " / CTB - " ctbname "\n Press Any Key to RUN, For Changing Plot Setting Press ESC then Edit Plot setting in PLOT (CTRL+P) then Save as Batch \n ")))

  (setq pppscaleonfit "fit"); fit to paper
  (setq pltovrd 1); set PLOTTRANSPARENCYOVERRIDE for transparent hatch is 2, default is 1

  (setq mmmvorder "N"); Layout Tab first is Y, Model Tab first is N 
  (setq mmmvhide "N"); Layout Tab object hiding is Y, or no is N

  ; error control
  (defun *error* (msg)
    (princ "error: ")
    (princ msg) 
    (setvar "osmode" 0)
    (princ)
  )

  (setq ent nil)

  (prompt "\n Select Title Blocks for Prints. (made by block)" ) 
  (setq pwgs (ssget (list (cons 0 "insert"))))


  ; these 2 modules for modified UCS dwg.

  ;; Doug C. Broad, Jr.
  ;; can be used with vla-transformby to
  ;; transform objects from the UCS to the WCS
  (defun UCS2WCSMatrix ()
    (vlax-tmatrix
      (append
        (mapcar
          '(lambda (vector origin)
	(append (trans vector 1 0 t) (list origin))
          ); end of lambda
          (list '(1 0 0) '(0 1 0) '(0 0 1))
          (trans '(0 0 0) 0 1)
        ); end of mapcar
        (list '(0 0 0 1))
      ); end of append
    ); end of vlax-tmatrix
  ); end of defun

  ;; transform objects from the WCS to the UCS
  (defun WCS2UCSMatrix ()
    (vlax-tmatrix
      (append
        (mapcar
          '(lambda (vector origin)
            (append (trans vector 0 1 t) (list origin))
          ); end of lambda
          (list '(1 0 0) '(0 1 0) '(0 0 1))
          (trans '(0 0 0) 1 0)
         );end of mapcar
         (list '(0 0 0 1))
       ); end of append
    ); end of vlax-tmatrix
  ); end of defun


  (if pwgs
    (progn
      (setq ss1 (SortSelectionSetByYXZ pwgs))
      (setq n 0)
      (repeat (sslength ss1)
        (setq ent (ssname ss1 n))
      
        ; these 3 lines is for modified UCS dwg.
        (vla-TransformBy (vlax-ename->vla-object ent) (UCS2WCSMatrix))
        (vla-getboundingbox (vlax-ename->vla-object ent) 'MinPt 'MaxPt)
        (vla-TransformBy (vlax-ename->vla-object ent) (WCS2UCSMatrix))
      
        (setq ppw1 (vlax-safearray->list MinPt)) 
        (setq ppw2 (vlax-safearray->list MaxPt))
    
        (setq vpw1 (list (car ppw2) (cadr ppw1))) ; lower-right point
        (setq vpw2 (list (car ppw1) (cadr ppw2))) ; upper-left point
    
        (setq wx (- (car ppw2) (car ppw1)) ) ; length of width 
        (setq wy (- (cadr ppw2) (cadr ppw1)) ) ; length of height

        (if (> wx wy) (setq wlp "l") (setq wlp "p")) ; landscape or portrait

        (setq pwwsel (ssget "W" ppw1 ppw2 )) ; all drawing
        (setq pdgscc1 (distance ppw1 ppw2))
        (setq pdgscc (/ pdgscc1 pdgsccpaper )) ; scaling to a3 drawing (if title block is not exactly a3, have to change this

        ; for LT Scaling
        ; (setq pdgscc4 (* pdgscc 4 )) ;ltscale 스케일의4배
        ; (setvar "ltscale"  pdgscc4) ; 치수스케일 도면축척과 동일 

        ; set osmode to X, P, S, I, D, C, M, E
        (setvar "osmode" 4335)

        ; for scaling, if pppscaleonfit is "fit" no need to use this value
        (setq PLOTSCALE (STRCAT "1=" (rtos (/ pdgscc1 pdgsccpaper) 2 0)))

        ; fit = scale to paper, on scale to scale value
        (if (= pppscaleonfit "fit") (setq PLOTSCALE "fit") (setq PLOTSCALE PLOTSCALE))

        (setq fname (getvar "dwgname")) ;get file name
        (setq fname (substr fname 1 (- (strlen fname) 4))) ;delete ".dwg"
        (setq sffx (rtos (getvar "cdate") 2 6)) ; make time string for add suffix to file name
        (setq fname (strcat PATH fname sffx ".pdf")) ;make path+filename+time 


        ; set PLOTTRANSPARENCYOVERRIDE value
        (command "PLOTTRANSPARENCYOVERRIDE" pltovrd) 

        ; for zoom to what block is now printing 
        ;(command "zoom" P_ppw1 P_ppw2) ; don't use it makes me headaches

        ; now we printing
        (command "-PLOT"  
               "Y" 
               "model"                        
               P_plotername               	; plotter name
               P_papername                	; paper name
               "M"                            	; model space
               wlp                            	; landscape or portrait
               "N" 
               "W"
               ppw2 ppw1
               PLOTSCALE
               "C"
               "Y"   
               ctbname
               "Y"              		; line weight 
               "A"                    	; Shaded Plot : all as view (A) / wire frame (W) / hide (H) / view style (V) / render (R)
               fname			; file name
	   "Y"                  	; save plot setting 
               "Y"                    	; execute plot
       )                     
       (command "delay"		; for artificial spool time for pdf, 10 second is 10000
	 PDFdelay
       )
       (command "osmode" "4335")
       (setq n (1+ n))
    ); end of repeat
   ); end of progn 
  ); end of if
  (command "PLOTTRANSPARENCYOVERRIDE" 1)
  (princ "\n Printing Complete! Check your dwg's folder")
  (princ path)
  (princ)
)


; https://forums.augi.com/showthread.php?137837-Sort-Selectionset-by-X-coord&p=1164232&viewfull=1#post1164232
; SortSelectionSetByXYZ by peter

; this is edited code for multisort XY, not original code
(defun sortListofSublistsbyItemX (lstOfSublists intItem intDirection)
 (if (> intDirection 0)
  (vl-sort lstOfSublists '(lambda (X Y) (if (eq (nth intItem X) (nth intItem Y)) 
                                                  (< (nth (- intItem 1) X) (nth (- intItem 1) Y))
                                                  (< (vl-prin1-to-string (nth intItem X)) (vl-prin1-to-string (nth intItem Y)))
                                               )
                             )
  )
  (vl-sort lstOfSublists '(lambda (X Y) (if (eq (nth intItem X) (nth intItem Y)) 
                                                  (> (nth (- intItem 1) X) (nth (- intItem 1) Y))
                                                  (> (vl-prin1-to-string (nth intItem X)) (vl-prin1-to-string (nth intItem Y)))
                                               )
                             )
  )
 )
)


(defun SelectionSetToList (ssSelections / intCount lstReturn)
 (if (and ssSelections 
          (= (type ssSelections) 'PICKSET)
     )
  (repeat (setq intCount (sslength ssSelections))
   (setq intCount  (1- intCount)
         lstReturn (cons (ssname ssSelections intCount) lstReturn)
   )
  )
 )
 (reverse lstReturn)
)


(defun ListToSelectionSet (lstOfEntities / ssReturn)
 (if lstOfEntities      
  (foreach entItem lstOfEntities
   (if (= (type entItem) 'ENAME)
    (if ssReturn 
     (setq ssReturn (ssadd entItem ssReturn))
     (setq ssReturn (ssadd entItem))
    )
   )
  )
 )
 ssReturn
)


(defun SortSelectionSetByYXZ (ssSelections /  lstOfSelections lstOfSublists lstSelections)
 (if
  (and 
   (setq lstSelections (SelectionSetToList ssSelections))
   (setq lstOfSublists (mapcar '(lambda (X)(cons X (cdr (assoc 10 (entget X))))) lstSelections))
   (setq lstOfSublists (sortlistofsublistsbyitemX lstOfSublists 2 1))
   (setq ssSelections (listtoselectionset (mapcar 'car lstOfSublists)))
  )
  ssSelections
 )
)


 

 

I edited it little bit to be simple. 

- eng translate

- set print path to drawing file's

- get print setting, you can change this in PLOT command window.

  push 'apply to layout' (same button we use in publish)

- you can adjust PDFdelay variable = delay time 3 seconds (= 3000)

  to fit your environment. if it makes jam.

- pdf sorted by Upper Left to Lower Right

Edited by exceed
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Why not go the next step for me layouts with all different size sheets and orientation one click on a menu and all the pdf's come out correct in one go no user interaction. Done for a client.

  • Thanks 2
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...