Sambuddy Posted March 5, 2020 Posted March 5, 2020 (edited) Hey guys, I wrote a routine that automatically change the setting or copy files from server onto C drive. What I am looking for is an idea to invoke these changes each time I make any changes on the source folder. I do not want to search for changes, but rather I was thinking let's say acaddoc evaluate something or through a lisp I tell it to < Update is available. Do you want to update? > for directories on anyone's C Drive if I make any changes on the source directory. I am looking for an idea... I have about 10-15 folders and sub-folders with all bunch of extensions on the server - when I finished editing them, I was thinking to write a routine to say < Ready to distribute? Yes or No > on my end. When I say "Yes", then for computers that are mapped on C drive, they would get a message "Update is available. Do you want to update? yes or no" I am just fiddling with this idea - any better idea? I DO NOT want to invoke it every time a session is starting or autocad is starting - rather a creative way to invoke it... on a different note, How do I evaluate blah.txt for a date change, if outdated then execute the copy routine, if not business as usual? Thanks guys Edited March 5, 2020 by Sambuddy Quote
Sambuddy Posted March 5, 2020 Author Posted March 5, 2020 I actually like this on : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-to-compare-quot-lsp-quot-last-modified-date/td-p/4638319 but I do not know how to work with it: If I add this to acaddoc to invoke and evaluate for a specific text file modified date, does anyone know how to make it happen? Let's say if I have a C:/blah/blah.txt on local machines but I went ahead and opened and saved T:/blah/blah.txt, on the cad startup, how can I evaluate T if older than the one on C then do things. Can someone help? Thanks guys ;; Returns T if f1 has been modified more recently than f2 (defun newer-p ( f1 f2 / compare ) (defun compare ( a b ) (cond ( (> (car a) (car b))) ( (and a b (= (car a) (car b))) (compare (cdr a) (cdr b)) ) ) ) (apply 'compare (mapcar '(lambda ( x ) (vl-list* (car x) (cadr x) (cdddr x))) (mapcar 'vl-file-systime (list f1 f2)) ) ) ) Quote
BIGAL Posted March 5, 2020 Posted March 5, 2020 You may need to convert to a number what systime returns. Ctoj is a julian date function as part of express tools. (setq a (vl-File-systime filename)) (ctoj (nth 0 a)(nth 1 a)(nth 2 a)(nth 3 a)(nth 4 a)(nth 5 a)) Quote
dlanorh Posted March 6, 2020 Posted March 6, 2020 4 hours ago, Sambuddy said: I actually like this on : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-to-compare-quot-lsp-quot-last-modified-date/td-p/4638319 but I do not know how to work with it: If I add this to acaddoc to invoke and evaluate for a specific text file modified date, does anyone know how to make it happen? Let's say if I have a C:/blah/blah.txt on local machines but I went ahead and opened and saved T:/blah/blah.txt, on the cad startup, how can I evaluate T if older than the one on C then do things. Can someone help? Thanks guys ;; Returns T if f1 has been modified more recently than f2 (defun newer-p ( f1 f2 / compare ) (defun compare ( a b ) (cond ( (> (car a) (car b))) ( (and a b (= (car a) (car b))) (compare (cdr a) (cdr b)) ) ) ) (apply 'compare (mapcar '(lambda ( x ) (vl-list* (car x) (cadr x) (cdddr x))) (mapcar 'vl-file-systime (list f1 f2)) ) ) ) See the last few lines for how to use it. file1 & file2 should include the full path to each file. (defun newer-p ( f1 f2 / compare ) (defun compare ( a b ) (cond ( (> (car a) (car b))) ( (and a b (= (car a) (car b))) (compare (cdr a) (cdr b)) ) ) ) (apply 'compare (mapcar '(lambda ( x ) (vl-list* (car x) (cadr x) (cdddr x))) (mapcar 'vl-file-systime (list f1 f2)) ) ) ) ;; ########################################################## ;; THIS IS THE EXAMPLE OF HOW TO USE IT (setq file1 "someFile" file2 "someOtherFile" ) (if (newer-p file1 file2) (princ (strcat file1 " is newer than " file2)) (princ (strcat file1 " is NOT newer than " file2)) ) Quote
Sambuddy Posted March 6, 2020 Author Posted March 6, 2020 (edited) @BIGAL Thanks Alan, you always saved my mess! Always! @dlanorh Great! Now I can make sense of this a bit. I should introduce my path. (setq file1 "someFile" file2 "someOtherFile" ) Since it is evaluating time for the condition to work, what happens if I modify blah.txt two times in a minute? Could you please let me know? Thank you again Edited March 6, 2020 by Sambuddy Quote
Sambuddy Posted March 6, 2020 Author Posted March 6, 2020 (edited) I actually found my answer for the question I asked about file 1 & 2. I mean ONLY the path part not the automatic checking... Now the second question would be, If I change file1.txt on my T drive, how do I make it so the action (in my case copying action) happens automatically without entering a command. What I am asking is how can I ask to evaluate file1.txt every X minutes? Your help is appreciated! Thanks Edited March 6, 2020 by Sambuddy Quote
hanhphuc Posted March 7, 2020 Posted March 7, 2020 OOTB i heard sort Dynamic WrapperX maybe able to utilize 3rd party library (but it only supports 32bit) or google monitoring software ? Quote
dlanorh Posted March 7, 2020 Posted March 7, 2020 12 hours ago, Sambuddy said: I actually found my answer for the question I asked about file 1 & 2. I mean ONLY the path part not the automatic checking... Now the second question would be, If I change file1.txt on my T drive, how do I make it so the action (in my case copying action) happens automatically without entering a command. What I am asking is how can I ask to evaluate file1.txt every X minutes? Your help is appreciated! Thanks Google : autolisp autosave reactor 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.