Author Topic: Lock Viewports in drawings in a folder  (Read 2943 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Lock Viewports in drawings in a folder
« on: August 27, 2015, 12:18:09 PM »
There is no routine that can lock all drawing viewports in a folder is there?
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Lock Viewports in drawings in a folder
« Reply #1 on: August 27, 2015, 12:32:53 PM »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Lock Viewports in drawings in a folder
« Reply #2 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.
Civil3D 2020

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Lock Viewports in drawings in a folder
« Reply #3 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) .

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Lock Viewports in drawings in a folder
« Reply #4 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

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Lock Viewports in drawings in a folder
« Reply #5 on: August 27, 2015, 01:06:04 PM »
Keyword directory... Lee yeah, that was in the back of my head
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Lock Viewports in drawings in a folder
« Reply #6 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?
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Lock Viewports in drawings in a folder
« Reply #7 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

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) :)

Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Lock Viewports in drawings in a folder
« Reply #8 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.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Lock Viewports in drawings in a folder
« Reply #9 on: August 28, 2015, 04:20:44 PM »
Jeff,
Thank you for pointing that out. I did not realize that would be a problem.
Civil3D 2020

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Lock Viewports in drawings in a folder
« Reply #10 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.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.