Sambuddy Posted April 9, 2020 Posted April 9, 2020 (robocopy sourcepath destinpath "*.*" "/MIR") (if (newer-p flstxt1 flstxt2) (progn (c:robocopy-T2C) (prompt "******<<< Files are being updated >>>******") (princ) );end_progn if true (progn (prompt "---* No action taken. Files are already up to date! *---") (princ) );end_progn or else );end_if Posted above are a few line from the code I combined that checks to see if a specific txt file is been updated, then executes robocopy to copy/ mirror files from T drive on server to C drive on local PC. The code above is a standalone lisp file that loads based on my code in acaddoc here: ;; LOAD CO-AL-T2C AT AUTOCAD STARTUP ;; IN CASE s::startup EXISTS ON ACADDOC (defun mystartupT2C () (load "C:\\TX Cad Config\\Lisp\\(CO-AL-T2C).LSP") ;; LOCAL DIRECTORY (c:CO-AL-T2C) ) ;END DEFUN (if s::startup (setq s::startup (append s::startup (quote ((mystartupT2C))))) (defun s::startup () (mystartupT2C)) ) ;END IF part of (CO-AL-T2C) is robocopy if you are wondering what (CO-AL-T2C).lsp does. The problem I have is in two parts if anyone cares to comment please: 1) if I am not connected to my VPN server, since it does not find T drive on the server, the entire acaddoc fails to execute, so I would not have command over any other routines that are independent of this routine that should work without being connected to VPN. Any solution? 2) it appears that the above routine (robocopy routine) happens to execute in strangest of circumstances for example when I publish or before attempting to autosave/ backup save I see my message hinting there is an attempt to robocopy even though the routine is in acaddoc and my understanding is that acaddoc only loads when I start of Autocad at the beginning not between commands. Thanks Quote
ronjonp Posted April 9, 2020 Posted April 9, 2020 (edited) 4 hours ago, Sambuddy said: 1) if I am not connected to my VPN server, since it does not find T drive on the server, the entire acaddoc fails to execute, so I would not have command over any other routines that are independent of this routine that should work without being connected to VPN. Any solution? A simple (findfile "T:\\SomeKnownFolder") would be my first check. Is there a reason you're updating this stuff in CAD ? This type of update IMO should be tied to the VPN client and ran after your drives are mapped. 4 hours ago, Sambuddy said: 2) it appears that the above routine (robocopy routine) happens to execute in strangest of circumstances for example when I publish or before attempting to autosave/ backup save I see my message hinting there is an attempt to robocopy even though the routine is in acaddoc and my understanding is that acaddoc only loads when I start of Autocad at the beginning not between commands. Sounds like you've tied something to a command reactor? Yikes! Edited April 9, 2020 by ronjonp Quote
Sambuddy Posted April 9, 2020 Author Posted April 9, 2020 Thanks for the reply @ronjonp. With this Virus and working at home, I am sort of left with updating certain blocks or adding stuff as I go along. We are connected to the server remotely each time by going through a complicated process to ensure the security of our plans, audits and surveys. if I'd be at the office, you are right, I would not even need to verify if T drive exists but working remotely has this main challenge for me. Cad drawings for any project in addition to the related documents are on the server but the cad setting (all lisps + general blocks, etc..) resides on every local PC hence the requirement for me to update T once and then through a process (reactor on every local PC) have everyone else get the update. Quote
ronjonp Posted April 9, 2020 Posted April 9, 2020 Why a reactor? If you use the findfile or VL-FILE-DIRECTORY-P as a check then you could alert ( maybe on open ) that they need to have that drive mapped for stuff to work. You could also try to map a drive using wscript like so .. here's an old function from my library: (defun rjp-mapdrive (ltr path name / wn sa) (if (and (setq wn (vlax-create-object "WScript.Network")) (setq sa (vlax-create-object "Shell.Application")) (not (vl-catch-all-apply 'vlax-invoke (list wn 'mapnetworkdrive ltr path false))) ) (progn (vlax-put (vlax-get (vlax-invoke sa 'namespace ltr) 'self) 'name name) (vlax-release-object wn) (vlax-release-object sa) ) ) (princ) ) ;; Call like so (rjp-mapdrive "T:" "\\\\servername_or_IP\\Folder" "NameofDrive") Quote
Sambuddy Posted April 9, 2020 Author Posted April 9, 2020 @ronjonp Did I thank you before? if not THANK YOU. You see sometimes I think I am over-complicating my life by thinking I need more than I have (many time it is the case)! You see, I did not even know VL-FILE-DIRECTORY-P existed - I remember trying VL-FILE-DIRECTORY and it did not recognize it as a function so I gave up. I am learning the power of lisp on the fly and do not have a guideline to go by but it is amazing the amount of help there is out there! Thank you @ronjonp for your Robocopy and this recent help. I still do not know how to make rjp-mapdrive work or what it does when you say "Mapping a drive" but I am sure it is great if I ever figure that out. Thanks Quote
ronjonp Posted April 9, 2020 Posted April 9, 2020 (edited) Glad to help out! Keep in mind that depending on your work VPN bandwidth, and the users internet connection some of these updates could take a while to complete depending on the amount of data you're pushing. Edited April 9, 2020 by ronjonp 1 Quote
BIGAL Posted April 12, 2020 Posted April 12, 2020 You can force a unzip to a certain directory this can be ran from lisp using shell so could make a zip update file. may be quicker for downloads. (startapp "c:\\program files\\7-zip\\7z x c:\\temp\\project2.zip -oc:\\temp\\ziptest") Quote
Sambuddy Posted April 13, 2020 Author Posted April 13, 2020 23 hours ago, BIGAL said: You can force a unzip to a certain directory this can be ran from lisp using shell so could make a zip update file. may be quicker for downloads. (startapp "c:\\program files\\7-zip\\7z x c:\\temp\\project2.zip -oc:\\temp\\ziptest") Thanks @BIGAL. I believe @ronjonp has an excellent solution, one that once executed continues to operate if even you close your AutoCAD or turn off your PC - I read through rpbocopy with Microsoft Windows and it seems to be the most powerful of them all. I added some error handling to @ronjonp routine and I quickly realized I did not even need it since the parameters are vast and powerful themselves. It was a great experience getting to know this command and ronjonp’s help to crack it. Quote
Recommended Posts
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.