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))
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.
Re: Can someone help me with reactors?
Quote:
Originally Posted by
ngwalters412556
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
Re: Can someone help me with reactors?
Quote:
Originally Posted by
ReachAndre
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)
Re: Can someone help me with reactors?
Quote:
Originally Posted by
ngwalters412556
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.
Re: Can someone help me with reactors?
No worries,
Happy Coding!