Jump to content
Sambuddy

Automated Reactor - Request for idea

Recommended Posts

Sambuddy
Posted (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

image.png.076dcd188ec2c5c5bcdf8aa1ee9ec40c.png

Edited by Sambuddy

Share this post


Link to post
Share on other sites
Sambuddy

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

 

Share this post


Link to post
Share on other sites
BIGAL

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

 

Share this post


Link to post
Share on other sites
dlanorh
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))
)

 

Share this post


Link to post
Share on other sites
Sambuddy
Posted (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 by Sambuddy

Share this post


Link to post
Share on other sites
Sambuddy
Posted (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 by Sambuddy

Share this post


Link to post
Share on other sites
hanhphuc

OOTB i heard sort Dynamic WrapperX maybe able to utilize 3rd party library (but it only supports 32bit)

or google  monitoring software ?

Share this post


Link to post
Share on other sites
dlanorh
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

Share this post


Link to post
Share on other sites
Sambuddy

Great!

 

Thanks

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...