Jump to content

Batch plot Lisp?


CadTechJGC184

Recommended Posts

I'm using 2006 at my new job. I was using 2008 at my prev. job. That was about 8 months ago. I was laid off. Anyways. I remember using alot of lisp's that they don't have at my new job. Batch plat is one of them.

 

I find myself opening and plotting each cad file. I KNOW theirs any easier way!

 

Any suggestions?

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    7

  • Commandobill

    4

  • Hardeight

    3

  • CadTechJGC184

    2

Top Posters In This Topic

Shouldn't you just be able to use the "publish" command? This should bring up a dialog box that allows you to add drawings, pick either model and/or layout tabs, other modifications if doing a dwf, and selecing a typical pagesetup from a dropdown box.

Link to comment
Share on other sites

I am not sure what cad release publish came in, but it should be available to everyone. I have been using it for a long time. If you have any questions about function just ask.

Link to comment
Share on other sites

This is my completely generic version of batch plot for 1 file. I know there's probably 256 people on here that could write it "better" but it works and i use it daily...

 

(defun printz()
 ; Set up variables
 (setq tabNum 0)
 (setq whileDummy 1)

 ; Begin loop
 (while (= whileDummy 1)
   ; Check if tab exists
   (if (/= (nth tabNum (layoutlist)) nil)
     (progn
   (setvar "ctab" (nth tabNum (layoutlist)))    ; Switch to tab

   (command "-plot" "" "" "" "" "" "" "")

   (setq tabNum (+ tabNum 1))            ; Incriment tab number
   )
     (setq whileDummy 2)
     )
   )
 (princ "you're done")(princ)
 )

Link to comment
Share on other sites

Could be re-written:

 

(defun printz  ()
 (foreach x  (layoutlist)
   (setvar "ctab" x)
   (command "-plot" "" "" "" "" "" "" ""))
 (princ "you're done")
 (princ))

Link to comment
Share on other sites

Very nice. Like i said though it works. Lee Mac I've noticed when i did a search on "batch plot" I got 131 hits... And with in the 30 or so i went through there was alot of good information. What does it take to get something stickied?

Link to comment
Share on other sites

Very nice. Like i said though it works. Lee Mac I've noticed when i did a search on "batch plot" I got 131 hits... And with in the 30 or so i went through there was alot of good information. What does it take to get something stickied?

 

Sorry, I don't quite follow, "stickied"?

Link to comment
Share on other sites

Sorry, I don't quite follow, "stickied"?

 

Stickied: when a thread is a sticky.

 

Basically when a thread stays at the top of the list instead of getting cycled through...

Link to comment
Share on other sites

I wrote one that I use at work, not really sure if it would help you out at all, since I uses a lot of our standards in the code to narrow down drawings and directories that I want to choose to print. Basically though, it gets a list of drawings, writes a script, runs the script to open all of them, and runs an autoprint lisp that I wrote, closes the drawing and moves on to the next.

If you want it I can post it, but like I said, you are gonna have to definitely modify it.

Link to comment
Share on other sites

Stickied: when a thread is a sticky.

 

Basically when a thread stays at the top of the list instead of getting cycled through...

 

Ah right, I see, perhaps a Mod can do it :)

 

But it would be a big task picking the correct thread or merging the best ones...

Link to comment
Share on other sites

I wrote one that I use at work, not really sure if it would help you out at all, since I uses a lot of our standards in the code to narrow down drawings and directories that I want to choose to print. Basically though, it gets a list of drawings, writes a script, runs the script to open all of them, and runs an autoprint lisp that I wrote, closes the drawing and moves on to the next.

If you want it I can post it, but like I said, you are gonna have to definitely modify it.

 

I think any input would be good

Link to comment
Share on other sites

(defun Fixsdi ()

(setq ACADOBJ (vlax-get-acad-object))

(setq DOCSOBJ (vlax-get-property acadobj "Documents"))

(setq DOCSLIST nil)

(vlax-for FOR-ITEM DOCSOBJ

(setq DOCSLIST (cons (strcat (vlax-get-property FOR-ITEM "Path") "\\"(vlax-get-property FOR-ITEM "Name"))DOCSLIST))

)

(setq DOCSLIST (reverse DOCSLIST))

(setq numdwg (length docslist))

(if (= numdwg 1)

(setvar "SDI" 1)

(progn

(setq choice (dos_msgbox "You currently have more than one drawing open.\nThis routine will save all changes and close these drawings.\nPress OK to proceed, Cancel to stop." "!WARNING!" 2 1))

(if (= choice 4)

(progn

(vlax-for doc (vla-get-documents (vlax-get-acad-object))

(vl-catch-all-apply

'vla-save

(list doc))

(vl-catch-all-apply

'vla-close

(list doc :vlax-False)))

(setvar "SDI" 1)

)

(progn

(setq continue "STOP")

(princ)

)

)

)

)

)

 

 

(defun dirset ()

(command "qsave")

(setq user (dos_username))

(cond ((= user "BLockhart")

(setq userp "Ben"))

((= user "CBearden")

(setq userp "Chris"))

((= user "LBrown")

(setq userp "Lavon"))

((= user "RChambers")

(setq userp "Ronnie"))

((= user "JMitchell")

(setq userp "Justin"))

((= user "JPrice")

(setq userp "Joe"))

((= user "LCooper")

(setq userp "Lonny"))

(setq userp (getstring "\n Please enter your first name: "))

);cond end

(setq maindir (dos_getdir "Select directory you wish to print:" (strcat "W:\\"userp"\\New Projects")))

(setq sublist (dos_subdir maindir))

(setq subnum (length sublist))

(setq cnt 0)

(setq pthlist (list))

(while (

(setq fldr (nth cnt sublist))

(setq pthlist (append pthlist (list (strcat maindir fldr))))

(setq cnt (+ cnt 1))

);while end

(setq dwglist (list))

(setq cnt 0)

(while (

(setq fldrpth (nth cnt pthlist))

(setq found nil)

(setq dwgnum (nth cnt sublist))

(while (= found nil)

(if(setq dwgpath (dos_search (strcat "A" dwgnum ".dwg") fldrpth))

(progn

 

(setq dwglist (append dwglist (list dwgpath)))

(setq found t))

);if end

(if(setq dwgpath (dos_search (strcat "B" dwgnum ".dwg") fldrpth))

(progn

 

(setq dwglist (append dwglist (list dwgpath)))

(setq found t))

);if end

(if(setq dwgpath (dos_search (strcat "C" dwgnum ".dwg") fldrpth))

(progn

 

(setq dwglist (append dwglist (list dwgpath)))

(setq found t))

);if end

(if(setq dwgpath (dos_search (strcat "D" dwgnum ".dwg") fldrpth))

(progn

 

(setq dwglist (append dwglist (list dwgpath)))

(setq found t))

);if end

(if (= found nil)

(progn

(alert (strcat "Your Drawing for number:"dwgnum" could not be found. Check your folder."))

(setq found t)

)

);if end

);while end

(setq cnt (+ cnt 1))

);while end

);defun end

 

(defun scriptwriter ()

(setvar "SDI" 1)

(setq scr (open (strcat maindir "batchplot.scr")"w"))

(setq cnt 0)

(foreach dwgs dwglist

(princ (strcat "(setvar " (chr 34) "filedia" (chr 34) "0)(command " (chr 34) ".open" (chr 34) ) scr)

(prin1 dwgs scr)

(princ ")" scr)

(princ (strcat "\n(load " (chr 34) "CADLisp.lsp" (chr 34) ")") scr)

(princ "\n" scr)

(princ "plotnohandsma" scr)

(princ "\n.QSAVE" scr)

(princ "\n\n" scr)

(setq cnt (+ cnt 1))

);for each end

(princ (strcat "(setvar " (chr 34) "SDI" (chr 34) " 0)")scr)

(princ (strcat "(command " (chr 34) "_new" (chr 34) (chr 34)"."(chr 34) ")" )scr)

(princ (strcat "\n(setvar " (chr 34) "filedia" (chr 34) " 1)\n")scr)

(close scr)

);defun end

 

(defun c:Plotdir ()

(fixsdi)

(if (= continue "STOP")

(princ)

(progn

(dirset)

(scriptwriter)

(close scr)

(command "script" (strcat maindir "batchplot.scr"))

(dos_delete (strcat maindir "batchplot.scr"))

)

)

);defun end

 

And here is the plot lisp I use that the script calls on.

 

;Function to automate plotting dialog.

;CAD Plotter.pc3 must be installed on the computer for this function to work.

;Drawings must be named correctly for this function to work.

;Drawings must have titleblock lower left corner at 0,0 point for the "A" drawing portrait/landscape detector to work. If Titleblock command was used, this should not be an issue.

(defun C:plotnohandsma ()

(setq space (getvar "ctab"))

(setq thisdwg (getvar "dwgname"))

(setq lngth (strlen thisdwg))

(setq number (- lngth 4))

(setq base (substr thisdwg 1 number))

(setq size base)

(setq cnt 0)

(repeat 10

(setq size (dos_strremove size (itoa cnt)))

(setq cnt (+ cnt 1))

)

(cond ((= size "A")

(progn

(setq tright (getvar "extmax"))

(setq xtr (nth 0 tright))

(setq ytr (nth 1 tright))

(if (

(setq ori "portrait")

(setq ori "landscape")

)

(setq paper (strcat "Letter (8½x11" (chr 34) ")" ))

))

((= size "B")

(progn

(setq ori "landscape")

(setq paper (strcat "ANSI B (11x17" (chr 34) ")" ))

))

((= size "C")

(progn

(setq ori "landscape")

(setq paper (strcat "Arch C (18x24" (chr 34) ")" ))

))

((= size "D")

(progn

(setq ori "landscape")

(setq paper (strcat "Arch D (24x36" (chr 34) ")" ))

))

((= size "G")

(progn

(setq ori "landscape")

(setq paper (strcat "ANSI B (11x17" (chr 34) ")" ))

))

((= size "g")

(progn

(setq ori "landscape")

(setq paper (strcat "ANSI B (11x17" (chr 34) ")" ))

))

)

(if (= space "Model")

(progn

(command "-plot" "Y" "" "CAD Plotter.pc3" paper "inches" ori "no" "extents" "Fit" "center" "yes" "bplot.ctb" "yes" "no" "n""yes" "yes")

)

(progn

(command "-plot" "Y" "" "CAD Plotter.pc3" paper "inches" ori "no" "extents" "fit" "center" "yes" "bplot.ctb" "yes" "no" "no" "no" "no" "yes" "yes")

)

)

 

)

Link to comment
Share on other sites

I've been working on this problem for just over 8 months now.

 

Using every trick I had, and many that I hadn't, I put together my (current) pride and joy, affectionately named BlitzPrint. Since it's customized for the plot devices we use here at work, I decided to dispense with the "fluff" and provide you good people with the important parts.. that is to say, just the Blitz.

 

That said, please allow me to humbly present my batch lisp. If you have any questions on its functionality, please tell me. Also, I know there are a few loose ends floating around, and I'm sure this could be started from scratch and re-worked into something more efficient. Please, if you have any comments or advice, let me know.

 

Part 1 of 2

 

; Blitz Batch Program
; Written by Mark Mercier, with a little help from my friends
; Version history:
;    08/06/08 v3 Alpha - printlayout, makeitso and dostuff functions operating
;    08/07/08 v3.1 Alpha - printsettings function operating
;    08/07/08 v3.14 Beta - makeitso function operating, first Beta version.
;    09/10/08 v3.141 - Most non-setting-related bugs removed and help option added. Improved layout list functionality.
;    01/23/09 v3.1415 - Added function for selection of multiple settings
;    01/30/09 v3.14159 - Added function for complex tab selection
;    04/03/09 v3.141592 - Added function for plotting all files in a directory
;    04/10/09 v3.1415926 - Added subdirectory capability
(defun c:bz() (blitz))

(defun blitz()
 (princ "\n** Blitz - v3.1415926 **\n")
 (printsettings)                    ; Determine print settings
 (printlayout)                        ; Determine layouts to plot
 (if warpFactor (engage) (makeitso))            ; Use collected variables to plot
 (princ)
 )

; - Begin function set for collecting print settings - ;

(defun printsettings()
 (setq multSettings nil)
 (setq printSetting nil)
 (setq printSettingList nil)
 (setq dirget "none")
 (setq dirPat "*")
 (setq dirSub "0")
 (setq warpFactor nil)
 (setq blitzPrintInputList nil)
 (setq copies 1)
 (setq printsetWhile 1)
 (GetPlotDevices)
 (while (= printsetWhile 1)
 (setq printsettingCheck nil)
 (princ "\n[0 - Setting1]")
 (setq printsettingGet (getstring "\nSelect number or [mUltiple/Directory/Files/?]: "))
   (cond
     
     ; Create a condition to test for user input. In the (dostuff) function, create a correlating condition which supplies said function.
     ; If plotting, create a function to check whether plot device exists, thereby allowing the user to remain in program loop upon device failure.
     ; Similarly, functions can be present within the condition to test any other user input aside from selected setting, as to prevent errors later.
     ((= printsettingGet "0") (printcheck))
     
     ((or (= (strcase printsettingGet) "D") (= (strcase printsettingGet) "DIRECTORY")) (directoryGet))
     ((= (strcase printsettingGet) "U") (setq multSettings 1))
     (t
      (princ "\nOption not available, please select another.")
      )
     )
   )
 (princ printSettingList)
 (setq blitzPrintInputList (append blitzPrintInputList (list (list (itoa copies)))))
 (setq blitzPrintInputList (append blitzPrintInputList (list printSettingList)))
 )

(defun printcheck()
 ; Check to see if the current selection is kosher. If plot device or other settings are unavailable, inform the user and return to main loop.
 (if (or (= printsettingCheck nil) (membercase printsettingCheck DEVICELIST))
   (progn
     (if multSettings
   (progn
     (setq printSettingList (append printSettingList (list printSettingGet)))
     (princ "\nPrint setting appended")

     (setq acceptWhile nil)
     (while (not acceptWhile)
       (princ "\nCurrent settings: ")(princ printSettingList)(princ)
       (setq acceptSettings (getstring "\nContinue with selected plot settings? [Yes/No/Remove] <No> "))
       (cond
         ((or (= acceptSettings "Y") (= acceptSettings "y"))
          (setq printsetWhile 2)
          (setq acceptWhile 1)
          )
         ((or (= acceptSettings "") (= acceptSettings "N") (= acceptSettings "n"))
          (setq acceptWhile 1)
          )
         ((or (= acceptSettings "R") (= acceptSettings "r"))
          (removeSetting)
          )
         (t
          (princ "\nOption not available, please try again")
          )
         )
       (if (not printSettingList)
         (progn
       (setq acceptWhile 1)
       (princ "\nAll selections removed.")
       )
         )
       )
     )
   (progn
     (setq printSettingList (list printsettingGet))
     (setq printsetWhile 2)
     (princ "\nPrint setting accepted")
     )
   )
     )
   (progn
     (princ "\nPrint setting not available.")
     )
   )
 )

(defun removeSetting()
 (setq removeWhile nil)
 (while (not removeWhile)
   (setq removeOption (getstring "\nEnter desired setting to remove: "))
   (if (member removeOption printSettingList)
     (progn
   (setq printSettingList (remFromList removeOption printSettingList))
   (setq removeWhile 1)
   (princ "\nSetting removed.")
   )
     (princ "\nSetting not available.")
     )
   )
 )

(defun directoryGet()
 (setq dirOpsWhile nil)
 (while (not dirOpsWhile)
   (princ (strcat "\nCurrent directory: " dirGet " - Current pattern: " dirPat ".dwg - Subdirectory level: " dirSub))
   (setq dirOp (getstring "\nEnter option [Directory/Subdirectories/Pattern/Clear/Files/Exit]: "))
   (cond
     ((= (strcase dirOp) "D")
      (setq pathGetWhile 1)
      (while pathGetWhile
    (setq dirGetGet (getstring "\nEnter directory search path in the form \"C:\\Folder 1\\Folder 2\" or [back]: "))
    (if (or (vl-directory-files dirGetGet nil 1) (= (strcase dirGetGet) "B"))
      (progn
        (if (not (= (strcase dirGetGet) "B")) (setq dirGet dirGetGet))
        (setq pathGetWhile nil)
        )
      (progn
        (princ "\nDirectory does not exist. Please try again.")
        )
      )
    )
      (if (= dirGet "") (setq dirGet "none"))
      )
     ((= (strcase dirOp) "S")
      (setq dirSubWhile 1)
      (while dirSubWhile
    (setq dirSubGet (getstring "\nEnter level of subdirectories [0-9]: "))
    (setq badSubList (list "0" "1" "2" "3" "4" "5" "6" "7" "8" "9"))
        (if (not (strmemlst badSubList (list dirSubGet)))
      (progn
        (princ "\nSelected characters not allowed. Please try again.")
        )
      (progn
        (setq dirSub dirSubGet)
        (setq dirSubWhile nil)
        )
      )
    )
      (if (= dirSub "") (setq dirSub "0"))
      )
     ((= (strcase dirOp) "P")
      (setq patternGetWhile 1)
      (while patternGetWhile
    (setq patternGet (getstring "\nEnter file search pattern using asterisk (*) as wildcard (do not include .dwg extention) <*>: "))
        (setq badList (list "\\" "/" ":" "." "?" "\"" "<" ">" "|"))
        (if (strmemlst badList (list patternGet))
      (progn
        (princ "\nSelected characters not allowed. Please try again.")
        (setq dirPat "*")
        )
      (progn
        (setq dirPat patternGet)
        (setq patternGetWhile nil)
        )
      )
        (if (= dirPat "") (setq dirPat "*"))
    )
      )
     ((= (strcase dirOp) "C")
      (setq dirPat "*")
      (setq dirget "none")
      (setq dirSub "0")
      (setq warpFactor nil)
      (princ "\nDirectory settings removed. Only the current drawing will be affected.")
      )
     ((= (strcase dirOp) "F")
      (filesShow)
      )
     ((= (strcase dirOp) "E")
      (setq allDirsList (subdir dirGet dirSub))
      (setq allFilesList (getfiles allDirsList dirPat))
      
      (if allFilesList
    (progn
      (princ "\nSettings accepted!")
      (setq warpFactor 1)
      (setq dirOpsWhile 1)
      )
    (progn
      (initget 1 "Y N")
      (setq lastchoice (getkword "\nSelected settings return a nil file list. Try again? [Y/N] <Y>: "))
      (if (= (strcase lastchoice) "N")
        (progn
          (setq dirGet "none")
          (setq dirPat "*")
          (setq dirSub "0")
          (setq warpFactor nil)
          (setq dirOpsWhile 1)
          (princ "\nDirectory settings removed. Only the current drawing will be affected.")
          )
        )
      )
    )
      )
     (t
      )
     )
   );/while
 (princ)
 )

(defun filesShow()
 (setq allDirsListShow (subdir dirGet dirSub))
 (setq allFilesListShow (getfiles allDirsListShow dirPat))
 (if allFilesListShow (princ allFilesListShow) (princ "\nNo files available with given settings."))
 (getstring "\nPress 'Enter' key to continue. ")
 )

Link to comment
Share on other sites

Part 2 of 2

 

I hope you find it useful ^.^

 


; - Begin function for collecting layout tabs to be printed - ;

(defun printlayout()
 ; Start
 (setq printlayWhileStart 1)
 (setq printlayWhileEnd 1)
 (setq printTabList nil)
 (setq printTabListEngage nil)
 (setq specialList nil)

 (princ (strcat "\nThere are " (rtos (length (layoutlist)) 2 0) " layout tabs in this drawing."))(princ)
 (while (= printlayWhileStart 1)
 (setq printlayStart (getstring "\nSelect starting layout number or [This/Current/All]: "))
   (setq printTabListEngage (append printTabListEngage (list printlayStart)))
   (cond
     ((or (= printlayStart "t") (= printlayStart "this") (= printlayStart "T") (= printlayStart "THIS"))
      (setq printlayWhileStart 2)
      (setq printlayWhileEnd 2)
      (setq printlayEnd 0)
      (setq var1num 0)
      (foreach var1 (layoutlist)
    (setq var1num (+ 1 var1num))
    (if (= var1 (getvar "ctab"))
      (progn
        (setq printStart (- var1num 1))
        (setq printEnd (- var1num 1))
        )
      )
    )
      (if (= (getvar "ctab") "Model")
    (progn
      (setq printlayWhileStart 1)
      (princ "Cannot plot Model tab.")
      )
    )
      )
     ((or (= printlayStart "a") (= printlayStart "all") (= printlayStart "A") (= printlayStart "ALL"))
      (setq printlayWhileStart 2)
      (setq printlayWhileEnd 2)
      (setq printlayEnd 0)
      (setq printStart 0)
      (setq printEnd (- (length (Get-Layout-List)) 1))
      )
     ((or (= printlayStart "c") (= printlayStart "current") (= printlayStart "C") (= printlayStart "CURRENT"))
      (setq printlayWhileStart 2)
      (setq var1num 0)
      (foreach var1 (layoutlist)
    (setq var1num (+ 1 var1num))
    (if (= var1 (getvar "ctab"))
      (progn
        (setq printStart (- var1num 1))
        )
      )
    )
      (if (= (getvar "ctab") "Model")
    (progn
      (setq printlayWhileStart 1)
      (princ "Cannot begin with Model tab.")
      )
    )
      )
     ((> (atoi printlayStart) (length (layoutlist)))
      (princ "\nStarting layout tab must not be greater than total layout tabs")
      )
     ((/= (strlen printlayStart) (strlen (rtos (atoi printlayStart) 2 0)))
      (princ "\nMalformed input")
      )
     ((/= (atoi printlayStart) 0)
      (setq printStart (- (atoi printlayStart) 1))
      (setq printlayWhileStart 2)
      )
     (t
      (princ (strcat printlayStart " is not an option."))
      )
     )
   )

 ; End
 (while (= printlayWhileEnd 1)
 (setq printlayEnd (getstring "\nSelect ending layout number or [End]: "))
   (setq printTabListEngage (append printTabListEngage (list printlayStart)))
   (cond
     ((or (= printlayEnd "E") (= printlayEnd "e"))
      (setq printlayWhileEnd 2)
      (setq printEnd (- (length (layoutlist)) 1))
      )
     ((= (atoi printlayEnd) 0)
      (princ "Error on input/tab does not exist.")
      )
     ((> printStart (atoi printlayEnd))
      (princ "end point is before start point")
      )
     ((= (nth (- (atoi printlayEnd) 1) (layoutlist)) nil)
      (princ "tab number does not exist")
      )
     (printlayEnd
      (setq printlayWhileEnd 2)
      (setq printEnd (- (atoi printlayEnd) 1))
      )
     (t
      (princ (strcat printlayEnd " is not an option."))
      )
     )
   )

 (if (not specialList)
   (progn
     (setq listVarA printStart)
     (while (<= listVarA printEnd)
       (setq printTabList (append printTabList (list listVarA)))
       (setq listVarA (1+ listVarA))
       )
     )
   (setq printTabList specialList)
   )

 (princ printTabList)(princ)
 (setq blitzPrintInputList (append blitzPrintInputList (list printTabListEngage)))
 )

; - Begin function set to use collected settings - ;

(defun makeitso()
 (repeat copies
   (foreach plotVar printTabList
     (setvar "ctab" (nth plotVar (layoutlist)))
     (foreach printSettingVar printSettingList
   (setq printSetting (atoi printSettingVar))
       (dostuff)
       )
     )
   )
 )

(defun engage()
 (makeScript)
 (command "script" scriptName)
 )

(defun makeScript()
 (setq blitzPrintString nil)
 (setq scriptName (strcat "C:\\blitzScriptFiles.scr"))
 (setq scriptOpen (open scriptName "w"))
 
 (setq settingsNabbed (nth 1 blitzPrintInputList))
 (setq string1 "(list")
 (foreach writeStringVar2 settingsNabbed
   (if (= (type writeStringVar2) 'INT) (setq writeStringVar2 (itoa writeStringVar2)))
   (setq string1 (strcat string1 " " "\"" writeStringVar2 "\""))
   )
 (setq line2 (strcat string1 ")"))
 (foreach line3Var (nth 2 blitzPrintInputList)
   (setq line3 (strcat "(printlayout) " line3Var))
   )

 (foreach blahvar filewithdirList
   (write-line (strcat "open " blahvar) scriptOpen)
   (write-line (strcat "(setq copies " (nth 0 (nth 0 blitzPrintInputList)) ")") scriptOpen)
   (write-line (strcat "(setq printSettingList " line2 ")") scriptOpen)
   (write-line line3 scriptOpen)
   (write-line "(makeitso)" scriptOpen)
   (write-line "close" scriptOpen)
   (write-line "y" scriptOpen)
   )
 (close scriptOpen)
 )

; - do stuff - ;
(defun dostuff()
 (setq echo (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 (cond
   ((= printSetting 0)
    ; Each condition reflects a setting in the initial menu. Input a custom function to perform on all selected drawing tabs.
    )
   (t
    )
   )
 (setvar "cmdecho" echo)
 )

; - Begin set of utility functions - ;

(defun subdir(subDirIn subDirLevel)
 (setq subDirsGet nil)
 (setq dirList nil)
 (setq dirListRet nil)
 
 (setq dirListIn (list subDirIn))
 (setq dirList (append dirList dirListIn))
 (setq dirListRet (append dirListRet dirListIn))
 (if (= (type subDirLevel) 'STR) (setq subDirLevel (atoi subDirLevel)))
 
 (repeat subdirLevel
   (setq subDirList nil)
   (foreach subDirVar dirList
     (setq subDirsGet (getSubdirectories subDirVar))
     (setq subDirList (append subDirList subDirsGet))
     )
   (setq dirListRet (append dirListRet subDirList))
   (setq dirList subDirList)
   )
 
 dirListRet
 )

(defun getSubdirectories(directory)
 (setq getSubList nil)
 (setq retSubList nil)
 
 (setq getSubList (vl-directory-files directory nil -1))
 (setq getSubList (reList1 getSubList "."))
 (setq getSubList (reList1 getSubList ".."))
 
 (foreach dirVar getSubList
   (setq subDirN (strcat directory "\\" dirVar))
   (setq retSubList (append retSubList (list subDirN)))
   )
 retSubList
 )

(defun getFiles(getFilesDir getFilesPat)
 (setq fileList nil)
 (setq filewithdirList nil)
 (foreach fileGetVar getFilesDir
   (setq fileList (append fileList (vl-directory-files fileGetVar (strcat getFilesPat ".dwg") 1)))

   (setq fwd1 nil)
   (setq fwd1 (append fwd1 (vl-directory-files fileGetVar (strcat getFilesPat ".dwg") 1)))
   (foreach fwdvar fwd1
     (setq filewithdirList (append filewithdirList (list (strcat fileGetVar "\\" fwdVar))))
     )
   )
 fileList
 )

(defun strmemlst(inSMLChar inSMLStri)
 (setq returnVarMS nil)
 (if (and (= (type inSMLChar) 'LIST)
      (= (type inSMLStri) 'LIST)
      (foreach checkvar inSMLChar (= (type checkVar) 'STR))
      (foreach checkvar inSMLStri (= (type checkVar) 'STR))
      (foreach checkvar inSMLChar (= (strlen checkVar) 1)))
   (progn
     (foreach toCheck inSMLStri
   (foreach chkWith inSMLChar
     (setq strmemsltCount 1)
     (repeat (strlen toCheck)
       (setq charGet (substr toCheck strmemsltCount 1))
       (if (= (strcase chkWith) (strcase charGet)) (setq returnVarMS T))
       (setq strmemsltCount (1+ strmemsltCount))
       )
     )
   )
     )
   (princ "\nMalformed input")
   )
 returnVarMS
 )

(defun reList1(listVar remVar)
 (setq returnVar nil)
 (setq dummyVar nil)
 (setq dummyList nil)
 (if (member remVar listVar)
   (progn
     (foreach checkVar listVar
   (if (= dummyVar nil)
     (progn
       (if (= remVar checkVar)
         (progn
       (setq dummyVar 1)
       )
         (setq dummyList (append dummyList (list checkVar)))
         )
       )
     (setq dummyList (append dummyList (list checkVar)))
     )
   )
     (setq returnVar dummyList)
     )
   (setq returnVar listVar)
   )
 returnVar
 )

(defun remFromList(remVar listVar)
 (setq returnVar nil)
 (setq dummyVar nil)
 (setq dummyList nil)
 (if (member remVar listVar)
   (progn
     (foreach checkVar listVar
   (if (= dummyVar nil)
     (progn
       (if (= remVar checkVar)
         (progn
       (setq dummyVar 1)
       )
         (setq dummyList (append dummyList (list checkVar)))
         )
       )
     (setq dummyList (append dummyList (list checkVar)))
     )
   )
     (setq returnVar dummyList)
     )
   (setq returnVar nil)
   )
 returnVar
 )

; -- GOODIES --
; Not written by me. I don't understand these at all.

; Function for gathering available plot devices. Original author unknown.
(defun GetPlotDevices ()
(vl-load-com)
(setq ad (vla-get-activedocument (vlax-get-acad-object)))
(vla-RefreshPlotDeviceInfo (vla-get-activelayout ad))
(setq DEVICELIST (vlax-safearray->list (vlax-variant-value
(vla-getplotdevicenames (vla-item (vla-get-layouts ad) "Model")))))
(princ)
)

; Return the Plotter configuration name
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
(defun GetActivePlotDevice ()
 (vla-get-ConfigName
   (vla-get-ActiveLayout
     (vla-get-activedocument
       (vlax-get-acad-object)
     )
   )
 )
)

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