TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MSTG007 on August 27, 2015, 12:18:09 PM

Title: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 27, 2015, 12:18:09 PM
There is no routine that can lock all drawing viewports in a folder is there?
Title: Re: Lock Viewports in drawings in a folder
Post by: ronjonp on August 27, 2015, 12:32:53 PM
Did you search? (https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=lock+all+viewports+in+autocad+site:theswamp.org)
Title: Re: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 27, 2015, 12:38:11 PM
Is there a way to Batch DWGS in a folder; to lock all viewports? Thanks for the search, still looking.
Title: Re: Lock Viewports in drawings in a folder
Post by: ronjonp on August 27, 2015, 12:57:43 PM
Do a search for locking all viewports in a drawing and processing a directory of drawings. Put the two together & you're golden  8) .
Title: Re: Lock Viewports in drawings in a folder
Post by: Lee Mac on August 27, 2015, 01:05:29 PM
Do a search for locking all viewports in a drawing and processing a directory of drawings. Put the two together & you're golden  8) .

This old program will do the latter: Script Writer (http://lee-mac.com/scriptwriter.html)
Title: Re: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 27, 2015, 01:06:04 PM
Keyword directory... Lee yeah, that was in the back of my head
Title: Re: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 28, 2015, 08:07:15 AM
Hey Lee, with your script writer, is there a way that I can write a script and autoload it via a macro and it run without the dialog box appearing?
Title: Re: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 28, 2015, 11:54:11 AM
LEEMac, This is an old post but still kinda fits on this thread. Remember you created the command that would add new layers and change layer colors to selected file in directory.

http://www.theswamp.org/index.php?topic=47376.msg523881 (http://www.theswamp.org/index.php?topic=47376.msg523881)

This was the lisp on top of the the GET FILES dialog.

Code: [Select]
(defun c:test ( / lst nco new oco old )
    (while (not (or (= "" (setq new (getstring t "\nSpecify new layer name <skip>: "))) (snvalid new)))
        (princ "\nInvalid layer name.")
    )
    (if (or (= "" new) (setq nco (acad_colordlg 7 nil)))
        (progn
            (while (not (or (= "" (setq old (getstring t "\nSpecify old layer name <skip>: "))) (snvalid old)))
                (princ "\nInvalid layer name.")
            )
            (if (or (= "" old) (setq oco (acad_colordlg 7 nil)))
                (if (setq lst (LM:getfiles "Select drawings to process" "" "dwg;dwt;dws"))
                    (LM:odbx
                       '(lambda ( doc / lay )
                            (if (/= "" new)
                                (vla-put-color (vla-add (vla-get-layers doc) new) nco)
                            )
                            (if (and (/= "" old)
                                    (not
                                        (vl-catch-all-error-p
                                            (setq lay
                                                (vl-catch-all-apply 'vla-item
                                                    (list (vla-get-layers doc) old)
                                                )
                                            )
                                        )
                                    )
                                )
                                (vla-put-color lay oco)
                            )
                        )
                        lst t
                    )
                )
            )
        )
    )
    (princ)
)

;;------------------=={ Get Files Dialog }==------------------;;
;;                                                            ;;
;;  An analog of the 'getfiled' function for multiple files.  ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  msg - Dialog box label; 'Select Files' if nil or "".      ;;
;;  def - Default directory; dwgprefix if nil or "".          ;;
;;  ext - File extension filter (e.g. "dwg;lsp"); "*" if nil  ;;
;;------------------------------------------------------------;;
;;  Returns:  List of selected files, else nil                ;;
;;------------------------------------------------------------;;
;;  Version 1.3    -    25-07-2013                            ;;
;;------------------------------------------------------------;;

(defun LM:getfiles ( msg def ext / *error* dch dcl des dir dirdata lst rtn )

    (defun *error* ( msg )
        (if (= 'file (type des))
            (close des)
        )
        (if (and (= 'int (type dch)) (< 0 dch))
            (unload_dialog dch)
        )
        (if (and (= 'str (type dcl)) (findfile dcl))


Is it possible for me to place any lisp routine in place of the original code? Or I guess the next question would be could it be able to run script commands? (Always thinking here) :)

Title: Re: Lock Viewports in drawings in a folder
Post by: Jeff_M on August 28, 2015, 03:43:49 PM
MSTG007, I know you use Civil3D so thought I'd throw a warning out here. If you find a solution to the batch drawings portion that uses ObjectDBX instead of opening each drawing in the editor, don't use it with C3D drawings. Especially with any that use Tag labels & Tables....all tags will be removed when editing C3D files outside of the editor.
Title: Re: Lock Viewports in drawings in a folder
Post by: MSTG007 on August 28, 2015, 04:20:44 PM
Jeff,
Thank you for pointing that out. I did not realize that would be a problem.
Title: Re: Lock Viewports in drawings in a folder
Post by: Kerry on August 28, 2015, 04:37:35 PM
MSTG007, I know you use Civil3D so thought I'd throw a warning out here. If you find a solution to the batch drawings portion that uses ObjectDBX instead of opening each drawing in the editor, don't use it with C3D drawings. Especially with any that use Tag labels & Tables....all tags will be removed when editing C3D files outside of the editor.


Wow! that would bite.