Author Topic: Switching drawings between different dirrectories  (Read 168 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 1968
Switching drawings between different dirrectories
« on: March 19, 2019, 03:29:49 PM »
I am trying to make the function ARCH:NOZ work between switching open drawing with files opened in different directories.

What type of funtion what I need when swiching from a directory F:\\ to a Z:\\ drawing and getting the warning message popup?


Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Special Alert Boxes VLAX ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Error-> (ARCH:MsgBox2 "Arch Program : Error" 16 "This is an Error Test" 4)
;;;Info-> (ARCH:MsgBox2 "Arch Program : Info" 48 "This is an Information Test" 4)
;;;Question-> (ARCH:MsgBox2 "Arch Program : Yes No" 4 "This is a Question Test\nplease make a selection" 0)
;;;QKeys-> (ARCH:MsgBox2 "Arch Program : Quick Keys" 64 "This is Quick Keys Test" 4)
;;;
;;; http://www.theswamp.org/index.php?topic=29537.0
;;; Patrick_35, GILE
;;; MsgBox
(defun ARCH:MsgBox2  (title buttons message time / return WshShell)
  (setq WshShell (vlax-create-object "WScript.Shell"))
  (setq return (vlax-invoke WshShell 'Popup message time title (itoa buttons)))
  (vlax-release-object WshShell)
  return)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Strip Folder Name ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;str2list by John Uhden, as posted to the adesk customization newsgroup
;;;renamed to Split to mimic VB(A) function
(defun ARCH:Split  (str pat / i j n lst)
  (cond ((/= (type str) (type pat) 'STR))
        ((= str pat) '(""))
        (T
         (setq i 0
               n (strlen pat))
         (while (setq j (vl-string-search pat str i))
           (setq lst (cons (substr str (1+ i) (- j i)) lst)
                 i   (+ j n)))
         (reverse (cons (substr str (1+ i)) lst)))))
;;Example: (setq 2nd (nth 3 (ARCH:Split (getvar "dwgprefix") "\\")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH:NOZ Warning Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:NOZ ()
  (if (=  (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")
      (ARCH:MsgBox2
       " Arch Program : Info"
       48
       "
     Arch Programę Alert
---------------------------------------------------------------------------
     You are in the \"Z:\" Directory! GET OUT!!!"
       4)
  )
  (princ))
(ARCH:NOZ)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 1968
Re: Switching drawings between different dirrectories
« Reply #1 on: March 20, 2019, 12:17:02 PM »
I did the warning at the menu level.
Adding the following to the Arch Menu file:

[$(eval,Current Directory is  ''$(getvar,dwgprefix)'')]
[$(eval,Warning  ''$(getvar,users5)'')]
[Activate Directory ''Alert Message''](ARCH:NOZ);

Code: [Select]
(defun ARCH:NOZ ()
  (setvar "users5" "Get Out of Z:\\ Directory")
  (if (=  (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")
      (ARCH:MsgBox2
       " Arch Program : Info"
       48
       "
     Arch Programę Alert
---------------------------------------------------------------------------
     You are in the \"Z:\" Directory! GET OUT!!!"
       4)
  )
  (princ))
(ARCH:NOZ)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 1968
Re: Switching drawings between different dirrectories
« Reply #2 on: March 20, 2019, 12:24:44 PM »
[$(eval,Current Directory is  ''$(getvar,dwgprefix)'')]
[$(eval,Message : $(getvar,users5))]
[Activate Directory ''Alert Message''](ARCH:NOZ);

Update the routine:

Code: [Select]
(defun ARCH:NOZ ()
  (cond
    ((=  (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")
      (setvar "users5" "Get Out of Z:\\ Directory")
      (ARCH:MsgBox2
       " Arch Program : Info"
       48
       "
     Arch Programę Alert
---------------------------------------------------------------------------
     You are in the \"Z:\" Directory! GET OUT!!!"
       4)
    )
    ((/=  (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")(setvar "users5" "This Directory is OK")))
  (princ))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64