Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

directory question

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Nett0
508 Views, 7 Replies

directory question

Is There a way of a lisp warn instantly when an archive is created in a directory?

 

Cheers

7 REPLIES 7
Message 2 of 8
BlackBox_
in reply to: Nett0

Welcome to the forums, and congrats on your first post!

 


@Nett0 wrote:

Is There a way of a lisp warn instantly when an archive is created in a directory?

 

Cheers


No not in the way you might be wanting... LISP can do many things, particularly the ActiveX side of the API, but LISP is relegated to a small number of what's called "Events" that it can monitor, or react to, when a given event is raised.

As an example, when you open a Document (read Drawing), or when a particular Command starts (i.e., Save, etc.), certain tasks can be performed programmatically.

 

However, to properly be notified when an archive is placed within the Active Document's location (read DwgPrefix), you'd have to step up into the .NET API, in order to implement an appropriate FileSystemWatcher.

 

While this may not be the answer you were hoping for, I do hope it helps.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 3 of 8
Nett0
in reply to: BlackBox_

Thanks BlackBox,

 

This is what i'm looking for, to be notified when an archive is placed within the Active Document's location.

 

But i've never worked with .NET before. Where can i find more about it?

 

Cheers

Message 4 of 8
BlackBox_
in reply to: Nett0

Just to reiterate, LISP can tell you if there's an archive file withint he DwgPrefix, it's simply a matter of when you'd be notified.

 

For example, here's a LISP Reactor which checks for any file with .RAR within the Active Document's location, following each Command (which is only being done for dmeonstration purposes; this would probably become quite annoying if used for daily production depending on how often a .RAR is added to your project):

 

(vl-load-com)

(defun c:FileWatcher ()

  ;; if FileWatcher is active
  (if *FileWatcher*

    ;; turn off
    (progn
      (vlr-remove *FileWatcher*)
      (setq *FileWatcher* nil)
      (setq FileWatcher:CommandEnded nil)
      (prompt "\n** FileWatcher off ** ")
    )

    ;; turn on
    (progn
      (setq *FileWatcher*
             (vlr-command-reactor
               nil
               '(
                 (:vlr-commandcancelled . FileWatcher:CommandEnded)
                 (:vlr-commandended . FileWatcher:CommandEnded)
                 (:vlr-commandfailed . FileWatcher:CommandEnded)
                )
             )
      )
      (defun FileWatcher:CommandEnded (rea cmd / archives)
        (if (setq archives
                   (vl-directory-files (getvar 'dwgprefix) "*.rar" 1)
            )
          (alert
            (apply
              'strcat
              (cons
                "Archive file(s) found in Active Document's location: \n\n"
                (mapcar
                  (function
                    (lambda (x)
                      (strcat x "\n")
                    )
                  )
                  (vl-sort archives '<)
                )
              )
            )
          )
        )
      )
      (prompt "\nFileWatcher loaded. ")
    )
  )
  (princ)
)

(c:FileWatcher)
(princ)

 

 

As for learnign about .NET development... That's a loaded question! LoL 

 

As many .NET developers will confirm, your best bet is to spend the next year learning to become adept at .NET development outside of AutoCAD, however, if you don't have time for that this thread may help get you started:

 

http://www.cadtutor.net/forum/showthread.php?69646-Where-to-start-with-.Net

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 5 of 8
Nett0
in reply to: Nett0

That helped me to solve what i wanted!

 

Thank you very much BlackBox.

Message 6 of 8
BlackBox_
in reply to: Nett0


@Nett0 wrote:

That helped me to solve what i wanted!

 

Thank you very much BlackBox.


You're welcome; I'm happy to help. :beer:

 

 

 

... When the Alert gets to be annoying, let me know? LoL

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 7 of 8
Nett0
in reply to: BlackBox_

LOL 😄

 

i've just change the code to just appear one time. =D

 

 

Cheers

Message 8 of 8
BlackBox_
in reply to: Nett0


@Nett0 wrote:

LOL 😄

 

i've just change the code to just appear one time. =D

 

 

Cheers


LoL - I knew it wouldn't take long.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost