Results 1 to 6 of 6

Thread: Can someone help me with reactors?

  1. #1
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Can someone help me with reactors?

    Hello all,
    I am trying to write my first program with reactors.
    Below is kind of a code explanation of what I am trying to do.

    Any help is appreciated.

    Thank you,
    Andre
    Code:
    (defun dgn-purge-check ()
      ;at save do the following:
          (command "qsave")
          (if (> filesize 1500kb)
    	(progn
    	  (dgnpurge)
    	  (command "Qsave")
    	  ))
      (princ))

  2. #2
    Member
    Join Date
    2013-08
    Posts
    23
    Login to Give a bone
    0

    Default Re: Can someone help me with reactors?

    Code:
    (defun foo ()
      (vl-load-com)
      
           ;;check if already loaded else load
      (foreach x 
        (list
          (cons "Purge_Save" (cons :vlr-SaveComplete 'Purge_Save_S))
        )
        (progn
          (if 
                 ;;if this
            (not
              (vl-position (car x)
                (mapcar (function strcase)
                  (mapcar (function vlr-data)
                    (cdar
                      (vlr-reactors :vlr-dwg-reactor)
                    )
                  )
                )
              )
            )
                 ;;then this
            (progn
              (vlr-dwg-reactor (car x) (list(cdr x)))
            )
                   ;;else this
            (princ (strcat "\n<<" (car x) " Has Already Been Loaded" ">>"))
          )
        )
      )
    
                ;;stuff you want to do at save
      (defun Purge_Save_S ()
        (if
                ;;if this 
          (> (vl-file-size (strcat (getvar "dwgprefix") (getvar "dwgname"))) 15000)
                ;;then this
          (progn
            (setvar "cmdecho" 0)
            (command "._purge" "all" "*" "N")
            (command "._purge" "regapps" "*" "N")
            (princ "\nDrawing has been purged...")
            (setvar "cmdecho" 1)
            (princ)
          )
               ;;else this
          (princ "Save Complete")
        )
    
      )
    
    )
    
       ;;run once to define and load
    (foo)


    That's the quick version, needs error handling just in case. Purge is a little slow to be doing at each save but whatever.

  3. #3
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Re: Can someone help me with reactors?

    Quote Originally Posted by ngwalters412556 View Post

    Purge is a little slow to be doing at each save but whatever.
    I agree, thats why I only want to do it if the drawing is larger than 1500kb.

    I cant yet figure out how to read the filesize though


    Thanks,
    Andre

  4. #4
    Member
    Join Date
    2013-08
    Posts
    23
    Login to Give a bone
    0

    Default Re: Can someone help me with reactors?

    Quote Originally Posted by ReachAndre View Post

    I cant yet figure out how to read the filesize though
    That's this part in the code before

    Code:
    (> (vl-file-size (strcat (getvar "dwgprefix") (getvar "dwgname"))) 15000)

  5. #5
    I could stop if I wanted to
    Join Date
    2015-12
    Posts
    385
    Login to Give a bone
    0

    Default Re: Can someone help me with reactors?

    Quote Originally Posted by ngwalters412556 View Post
    That's this part in the code before
    You know, I shoudl really scroll donw and read the whole code. Sorry I didnt see it.

  6. #6
    Member
    Join Date
    2013-08
    Posts
    23
    Login to Give a bone
    0

    Default Re: Can someone help me with reactors?

    No worries,

    Happy Coding!

Similar Threads

  1. Reactors???
    By cosmarchy in forum AutoLISP
    Replies: 5
    Last Post: 2012-09-04, 04:28 PM
  2. need some help with reactors
    By darren_lambett in forum AutoLISP
    Replies: 1
    Last Post: 2009-04-20, 12:31 PM
  3. Reactors????
    By LLAW3224 in forum AutoLISP
    Replies: 2
    Last Post: 2005-03-04, 12:44 PM
  4. Can this be done with reactors?
    By kieren in forum AutoLISP
    Replies: 5
    Last Post: 2004-10-06, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •