Model Space Batchplot lisp

Model Space Batchplot lisp

3arizona
Advocate Advocate
1,499 Views
8 Replies
Message 1 of 9

Model Space Batchplot lisp

3arizona
Advocate
Advocate

i want to add a 1 or 2 extra columns.  when i change the columns to 5, lisp only prints 5 sheets regardless of the quantity i impute. 

 

This how it works:

pick top corner of 8.5 x 11 sheet (sheet parameter are set)

it will prompt how may sheets you want to plot

plots 4 columns and however may sheets (rows) you want to plot after

 

this is the lisp.

(defun C:test ()
  (setq startpt (getpoint "\nSelect top-left corner of billpage grid: "))
  (setq bpcount (getint "\nSpecify number of billpages: "))
  (setq w_rows (fix (/ bpcount 4.0)))
  (setq bpheight 21.0)
  (setq bpwidth 16.0)
  (setq bpgap 2.5)
  (setq p_col (fix (rem bpcount 4)))
  (setq row 1)
  (setq x_0 (car startpt))
  (setq y_0 (cadr startpt))
  (while (<= row w_rows)
    (setq col 0)
    (while (<= col 3)
      (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* row bpheight) (* (- row 1) bpgap)))))
      (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* (- row 1) (+ bpheight bpgap)))))
      (command "-plot")
      (command "y")
      (command "")
      (command "Bluebeam PDF.pc3")
      (command "Letter")
      (command "i")
      (command "p")
      (command "n")
      (command "w")
      (command bl)
      (command tr)
      (command "f")
      (command "")
      (command "y")
      (command "")
      (command "y")
      (command "")
      (command "n")
      (command "n")
      (command "y")
      (setq col (+ col 1))
    )
    (setq row (+ row 1))
  )
  (if (/= p_col 0)
    (progn
      (setq col 0)
      (while (<= col (- p_col 1))
	(setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* (+ 1 w_rows) bpheight) (* w_rows bpgap)))))
	(setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* w_rows (+ bpheight bpgap)))))
	(command "-plot")
	(command "y")
	(command "")
	(command "")
	(command "")
	(command "i")
	(command "p")
	(command "n")
	(command "w")
	(command bl)
	(command tr)
	(command "f")
	(command "")
	(command "y")
	(command "")
	(command "y")
	(command "")
	(command "n")
	(command "n")
	(command "y")
	(setq col (+ col 1))
      )
    )
  )
  (princ)


)

 

 

 

0 Likes
Accepted solutions (1)
1,500 Views
8 Replies
Replies (8)
Message 2 of 9

maratovich
Advisor
Advisor

Do you have the same title blocks ?

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 9

3arizona
Advocate
Advocate

yes, it's the same TB 

 

0 Likes
Message 4 of 9

Ranjit_Singh
Advisor
Advisor

Try below and see if the right co-ordinates print. Then replace the print portion of code with plot as in Post #1.

(defun c:test  (/ bl bpcount bpgap bpheight bpwidth col coln p_col row startpt tr w_rows x_0 y_0)
 (setq startpt  (getpoint "\nSelect top-left corner of billpage grid: ")
       bpcount  (getint "\nSpecify number of billpages: ")
       coln     6; Update column number here
       w_rows   (fix (/ bpcount coln))
       bpheight 21.0
       bpwidth  16.0
       bpgap    2.5
       p_col    (fix (rem bpcount coln))
       row      1
       x_0      (car startpt)
       y_0      (cadr startpt))
 (while (<= row w_rows)
  (setq col 0)
  (princ "\n************")
  (princ (strcat "\nrow: " (itoa row) "\n"))
  (while (< col coln)
   (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* row bpheight) (* (- row 1) bpgap)))))
   (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* (- row 1) (+ bpheight bpgap)))))
   (print bl)
   (print tr)
   (terpri)
   (setq col (+ col 1)))
  (setq row (+ row 1)))
 (princ "\n************")
 (princ (strcat "\nrow: " (itoa row) "\n"))
 (cond ((/= p_col 0)
        (setq col 0)
        (while (<= col (- p_col 1))
         (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* (+ 1 w_rows) bpheight) (* w_rows bpgap)))))
         (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* w_rows (+ bpheight bpgap)))))
         (print bl)
         (print tr)
         (terpri)
         (setq col (+ col 1)))))
 (princ))
0 Likes
Message 5 of 9

maratovich
Advisor
Advisor

I do not know Lisp well, but if there is not a solution here - there is another method of automatic printing from the model.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 6 of 9

3arizona
Advocate
Advocate

When i paste the top portion of the my print properties it only gives me 1 sheet regardless of the quantity i ask for. If i change the bottom print potion as above it goes haywire, printing nonstop.   print parameters/coordinates are good 

 

I don't know much about lisps. i thought it was a simple fix 

 

see

(defun c:test1  (/ bl bpcount bpgap bpheight bpwidth col coln p_col row startpt tr w_rows x_0 y_0)
 (setq startpt  (getpoint "\nSelect top-left corner of billpage grid: ")
       bpcount  (getint "\nSpecify number of billpages: ")
       coln     6; Update column number here
       w_rows   (fix (/ bpcount coln))
       bpheight 21.0
       bpwidth  16.0
       bpgap    2.5
       p_col    (fix (rem bpcount coln))
       row      1
       x_0      (car startpt)
       y_0      (cadr startpt))
 (while (<= row w_rows)
  (setq col 0)
  (princ "\n************")
  (princ (strcat "\nrow: " (itoa row) "\n"))
  (while (< col coln)
   (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* row bpheight) (* (- row 1) bpgap)))))
   (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* (- row 1) (+ bpheight bpgap)))))
      (command "-plot")
      (command "y")
      (command "")
      (command "Bluebeam PDF.pc3")
      (command "Letter")
      (command "i")
      (command "p")
      (command "n")
      (command "w")
      (command bl)
      (command tr)
      (command "f")
      (command "")
      (command "y")
      (command "")
      (command "y")
      (command "")
      (command "n")
      (command "n")
      (command "y"))
   (terpri)
   (setq col (+ col 1)))
  (setq row (+ row 1)))
 (princ "\n************")
 (princ (strcat "\nrow: " (itoa row) "\n"))
 (cond ((/= p_col 0)
        (setq col 0)
        (while (<= col (- p_col 1))
         (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* (+ 1 w_rows) bpheight) (* w_rows bpgap)))))
         (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* w_rows (+ bpheight bpgap)))))
      (command "-plot")
      (command "y")
      (command "")
      (command "Bluebeam PDF.pc3")
      (command "Letter")
      (command "i")
      (command "p")
      (command "n")
      (command "w")
      (command bl)
      (command tr)
      (command "f")
      (command "")
      (command "y")
      (command "")
      (command "y")
      (command "")
      (command "n")
      (command "n")
      (command "y"))
         (terpri)
         (setq col (+ col 1)))))
 (princ))

lisp:  

0 Likes
Message 7 of 9

maratovich
Advisor
Advisor

Attach a sample .dwg file

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 8 of 9

Ranjit_Singh
Advisor
Advisor
Accepted solution

@3arizona wrote:

When i paste the top portion of the my print properties it only gives me 1 sheet regardless of the quantity i ask for. If i change the bottom print potion as above it goes haywire, printing nonstop.   print parameters/coordinates are good 

............


Here is how it works at my end. Be sure to follow the prompts at your command prompt for -plot and follow the sequence exactly in both the command functions.

(defun c:test  (/ bl bpcount bpgap bpheight bpwidth col coln p_col row startpt tr w_rows x_0 y_0)
 (setq startpt  (getpoint "\nSelect top-left corner of billpage grid: ")
       bpcount  (getint "\nSpecify number of billpages: ")
       coln     6 ; Update column number here
       w_rows   (fix (/ bpcount coln))
       bpheight 21.0
       bpwidth  16.0
       bpgap    2.5
       p_col    (fix (rem bpcount coln))
       row      1
       x_0      (car startpt)
       y_0      (cadr startpt))
 (while (<= row w_rows)
  (setq col 0)
  (while (< col coln)
   (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* row bpheight) (* (- row 1) bpgap)))))
   (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* (- row 1) (+ bpheight bpgap)))))
   (command "-plot" "y" "" "Adobe PDF.pc3" "Letter" "i" "p" "n" "w" bl tr "f" "" "y" "" "y" "" "n" "n" "y")
   (setq col (+ col 1)))
  (setq row (+ row 1)))
 (cond ((/= p_col 0)
        (setq col 0)
        (while (<= col (- p_col 1))
         (setq bl (list (+ x_0 (* col (+ bpwidth bpgap))) (- y_0 (+ (* (+ 1 w_rows) bpheight) (* w_rows bpgap)))))
         (setq tr (list (+ x_0 (+ (* (+ col 1) bpwidth) (* col bpgap))) (- y_0 (* w_rows (+ bpheight bpgap)))))
         (command "-plot" "y" "" "Adobe PDF.pc3" "Letter" "i" "p" "n" "w" bl tr "f" "" "y" "" "y" "" "n" "n" "y")
         (setq col (+ col 1)))))
 (princ))

MS_batch_plot.gif 

Message 9 of 9

3arizona
Advocate
Advocate

Ranjit.Singh. 

 

Thanks, works perfect and friendlier.   

0 Likes