Author Topic: Open and New Command Failing  (Read 1322 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7529
Open and New Command Failing
« on: June 22, 2005, 06:49:10 PM »
So do any of you have an idea what would cause the open and new command not to work all the time? I'd say about every 3rd time I issue the command it just goes to the command line and nothing happens. :?:

I do have save reactors setup in the drawing as well as VBA to set layers.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Open and New Command Failing
« Reply #1 on: June 22, 2005, 07:08:08 PM »
So I think I've narrowed it down to this lisp:

Code: [Select]
;_____________________________________________________________________________
;;MAKES COPY OF DRAWING IN C:\AutoCAD-BAK AND UPDATES ON SAVE AND QSAVE
;_____________________________________________________________________________


(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandEnded . copydwg)))
(defun copydwg (calling-reactor endcommandInfo / destdir dwgdir t-o-d)
  (setq thecommandend (nth 0 endcommandInfo))
  (cond
    (= thecommandend "SAVE")
    (= thecommandend "QSAVE")
  )
(if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
    (progn

   (defun t-o-d (/ curdate curtime)
     (setq   curdate (rtos (fix (getvar 'cdate)) 2 0)
      curtime (strcat (substr curdate 5 2) "-" (substr curdate 7 2) "-" (substr curdate 1 4)))
   )

(defun hour (/ ctime ampm stime)
  (setq ctime (rtos (rem (getvar 'cdate) 1) 2 6)
       ampm  (if (<= (atof (substr ctime 3 2)) 12) "AM" "PM")
       stime (strcat (substr ctime 3 2)))
)

               ;Makes C:\AutoCAD-BAK\currentdate\hour if it doesn't already exist

   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/")))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/"))
   )

   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d))))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d)))
   )


   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour))))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour)))
   )

               ;For some reason the files get huge if not deleted then saved on top of

   (if (findfile (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname)))
     (vl-file-delete (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname)))
   )

   (setq destdir (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname))
         dwgdir  (strcat (getvar 'dwgprefix) (getvar 'dwgname))
   )
   (vl-file-copy dwgdir destdir T)
      )
    )
  )



Could someone take a look and see if there is anything blaring that would affect these commands?

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Open and New Command Failing
« Reply #2 on: June 23, 2005, 09:40:43 AM »
No ideas?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

daron

  • Guest
Open and New Command Failing
« Reply #3 on: June 23, 2005, 11:02:46 AM »
Not from me, sorry.

ronjonp

  • Needs a day job
  • Posts: 7529
Open and New Command Failing
« Reply #4 on: June 24, 2005, 12:24:32 PM »
I reconfigured the lisp a little and now all is well:


Code: [Select]
;_____________________________________________________________________________
;;MAKES COPY OF DRAWING IN C:\AutoCAD-BAK
;_____________________________________________________________________________


(defun copydwg (/ destdir dwgdir t-o-d hour)
(if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
    (progn

   (defun t-o-d (/ curdate curtime)
     (setq   curdate (rtos (fix (getvar 'cdate)) 2 0)
      curtime (strcat (substr curdate 5 2) "-" (substr curdate 7 2) "-" (substr curdate 1 4)))
   )

(defun hour (/ ctime ampm stime)
  (setq ctime (rtos (rem (getvar 'cdate) 1) 2 6)
       ampm  (if (<= (atof (substr ctime 3 2)) 12) "AM" "PM")
       stime (strcat (substr ctime 3 2)))
)

               ;Makes C:\AutoCAD-BAK\currentdate\hour if it doesn't already exist

   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/")))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/"))
   )

   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d))))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d)))
   )


   (if (not
       (vl-file-directory-p (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour))))
       (vl-mkdir (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour)))
   )

               ;For some reason the files get huge if not deleted then saved on top of

   (if (findfile (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname)))
     (vl-file-delete (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname)))
   )

   (setq destdir (strcat "C:/AutoCAD-BAK/" (t-o-d) "/" (hour) "/" (getvar 'dwgname))
         dwgdir  (strcat (getvar 'dwgprefix) (getvar 'dwgname))
   )
   (vl-file-copy dwgdir destdir T)
      )
    )
  )
(copydwg)


;_____________________________________________________________________________
;;COMMAND REACTORS
;_____________________________________________________________________________


(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))


(defun endCommand (calling-reactor endcommandInfo / thecommandend)
(setq thecommandend (nth 0 endcommandInfo))
(cond
  ((= thecommandend "QSAVE") (copydwg))
  ((= thecommandend "SAVE") (copydwg))
)
)


 :D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC