Author Topic: make several copies from a plot script file  (Read 2826 times)

0 Members and 1 Guest are viewing this topic.

EagerToLearnCad

  • Guest
make several copies from a plot script file
« on: January 08, 2009, 04:33:47 PM »
Hello,

Below is an example of a script file from this site. I am going to use this example
to batch plot drawings. Can somebody please edit this so that I can make several
copies of the plots. Let say I need to plot 3 copies of each file I selected. I'd
like it to run it 3 times. Run 1 set first..then the second..then the third.


;batch_anything.lsp
;Created XXXXXXXX
;Date:   Sept of 2002
;Description:   Batch Process
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(DEFUN C:batch_anything ()

;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed

   (setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
   (setq wutdir (vl-filename-directory dfil))
   (setq wutfiles (vl-directory-files wutdir "*.dwg"))

   (setq scrfile (open "c:\\scrfile.scr" "w"))
   (close scrfile)
   (setq scrfile (open "c:\\scrfile.scr" "a"))

(foreach n wutfiles
   (setq n2 (strcat "\""wutdir "\\" n "\""))
   (setq n2 (vl-string-translate "\\" "\\" n2))
   (setq scrline (strcat "open" " " n2 " " "(load\"YOURLISP\")" " " "YOURLISP" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
   (write-line scrline scrfile)
   (princ)
)

   (close scrfile)
(command "script" "c:\\scrfile")

(princ "\n***Batch complete.***")
(princ)


);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: make several copies from a plot script file
« Reply #1 on: January 08, 2009, 04:45:06 PM »
You need to replace YOURLISP with a lisp of your choosing.
In your case you need to create a lisp to plot the file 3 times.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: make several copies from a plot script file
« Reply #2 on: January 08, 2009, 04:49:04 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

EagerToLearnCad

  • Guest
Re: make several copies from a plot script file
« Reply #3 on: January 08, 2009, 06:11:19 PM »
I did but its really beyond me.

EagerToLearnCad

  • Guest
Re: make several copies from a plot script file
« Reply #4 on: January 08, 2009, 07:19:28 PM »
Cab,

Thank you. I'm okay now. After studying (more like staring) at that other example
I somewhat picked up "repeat". I tired it and my script works. Thanks again!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: make several copies from a plot script file
« Reply #5 on: January 08, 2009, 09:55:41 PM »
Glad you worked it out. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

EagerToLearnCad

  • Guest
Re: make several copies from a plot script file
« Reply #6 on: January 09, 2009, 02:49:06 PM »
Okay...I'm almost done with my code to produce a plot script file.
Here is a simplified version of of the code. I use "alert box"
instead of "prompt" for now.


(defun c:test ()
(setq list '("Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg"))
(setq N 0)
(while (< N (length List))
       (setq Dwg# (itoa (+ N 1)))
       (setq TotalDwg (itoa (length List)))
       (setq Dwg (nth N list))
       (setq Dwgname (strcat "processing.. " Dwg))
       (setq Dwginfo (strcat "Drawing " Dwg# " of " TotalDwg))
       (setq Process (strcat  Dwgname "\n" dwginfo))
;      (command "plot"...........)   
       (Alert Process)
       (setq N (1+ N))
);while 
);defun


Now here is the code with "repeat 3"..to plot 3 sets
from the 3 drawings. A total of 9.

(defun c:test1 ()
(setq list '("Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg"))
(repeat 3
(setq N 0)
(while (< N (length List))
       (setq Dwg# (itoa (+ N 1)))
       (setq TotalDwg (itoa (length List)))
       (setq Dwg (nth N list))
       (setq Dwgname (strcat "processing.. " Dwg))
       (setq Dwginfo (strcat "Drawing " Dwg# " of " TotalDwg))
       (setq Process (strcat  Dwgname "\n" dwginfo))
;      (command "plot"...........)   
       (Alert Process)
       (setq N (1+ N))
);while 
);repeat
);defun

Question/Request:
Can somebody please edit this so that that it will count 1 to 9 instead of
1 to 3 three times and that the total number of drawings is 9 instead of 3.

dustinthiesse

  • Guest
Re: make several copies from a plot script file
« Reply #7 on: January 09, 2009, 03:02:32 PM »
Now here is the code with "repeat 3"..to plot 3 sets
from the 3 drawings. A total of 9.

(defun c:test1 ()
(setq list '("Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg"))
(repeat 3
(setq N 0)
(while (< N (length List))
       (setq Dwg# (itoa (+ N 1)))
       (setq TotalDwg (itoa (length List)))
       (setq Dwg (nth N list))
       (setq Dwgname (strcat "processing.. " Dwg))
       (setq Dwginfo (strcat "Drawing " Dwg# " of " TotalDwg))
       (setq Process (strcat  Dwgname "\n" dwginfo))
;      (command "plot"...........)  
       (Alert Process)
       (setq N (1+ N))
);while 
);repeat
);defun

Question/Request:
Can somebody please edit this so that that it will count 1 to 9 instead of
1 to 3 three times and that the total number of drawings is 9 instead of 3.


You could define your "repeat" number as a variable and drive everything with that...
Code: [Select]
(defun c:test1 ()
  (setq list '("Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg")
           [color=red]repeat# 3[/color]
  )
  (repeat [color=red]repeat#[/color]
    (setq N 0)
    (while (< N (length List))
       (setq Dwg# (itoa (+ N 1)))
       (setq TotalDwg (itoa (length List)))
       (setq Dwg (nth N list))
       (setq Dwgname (strcat "processing.. " Dwg))
       (setq Dwginfo (strcat "Drawing " Dwg# " of " TotalDwg))
       (setq Process (strcat  Dwgname "\n" dwginfo))
;      (command "plot"...........)   
       (Alert Process)
       (setq N (1+ N))
);while 
);repeat
[color=red](setq total#(* repeat# (length list)))[/color]
);defun

EagerToLearnCad

  • Guest
Re: make several copies from a plot script file
« Reply #8 on: January 09, 2009, 03:15:38 PM »
Hi,

Thank you. But it is stll alerting 1 to 3 three times. It should alert 1 to 9 one time.
Defining repeat was not the issue. I just hard coded the number "3" as an example.



dustinthiesse

  • Guest
Re: make several copies from a plot script file
« Reply #9 on: January 09, 2009, 03:41:02 PM »
Hi,

Thank you. But it is stll alerting 1 to 3 three times. It should alert 1 to 9 one time.
Defining repeat was not the issue. I just hard coded the number "3" as an example.

Code: [Select]
(defun c:test1 ()
  (setq dwglist '("Drawing1.dwg" "Drawing2.dwg" "Drawing3.dwg")
           repeat# 3
           TotalDwg(* (length dwglist) repeat#)
           dwg# 1
  )
  (repeat repeat#
    (setq N 0)
    (while (< N (length dwgList))
       ;(setq TotalDwg (itoa (length dwgList)))
       (setq Dwg (nth N dwglist))
       (setq Dwgname (strcat "processing.. " Dwg))
       (setq Dwginfo (strcat "Drawing " (itoa Dwg#) " of " (itoa TotalDwg)))
       (setq Process (strcat  Dwgname "\n" dwginfo))
;      (command "plot"...........)   
       (Alert Process)
       (setq N (1+ N)
                dwg#(1+ dwg#)
       )
);while 
);repeat
(setq total#(* repeat# (length list)))
);defun

Sorry...I misunderstood your first question.  Perhaps something like this?

EagerToLearnCad

  • Guest
Re: make several copies from a plot script file
« Reply #10 on: January 09, 2009, 04:01:11 PM »
d-unit,

Thank You!!!!!...Exactly what I needed. Have a good weekend.