Jump to content

AutoLisp help... Regen at intervals


Recommended Posts

Posted

Hello,

 

I'm new to Lisps and would appreciate some help / pointers!!  I've been looking at the forums for an answer but don't seem to be able to find it.

 

Within a very simple drawing, I have a very simple block with a number of attributes, of which are some basic calculations. Once the values are changed, I need to regen in order to see the calculated result.

 

The downside of this, is that if a user doesn't regen, the later calculations will be wrong.

 

I've messed about with various regen options etc, but can't see a way to automate this?

 

I'm now thinking that an AutoLisp which automatically regens the drawing, once every 2 seconds for example, will for the values to be correct.

 

@Lee Mac  I've seen a number of your replies to similar requests, including some relating to 'Reactors'. It looks like you're a man who knows these things!! 

 

Is this an option?

 

Thanks All!

 

Posted

Welcome to the forum.

Please try this untested codes and let me know how you get on with.

Just add the codes into your acaddoc.lsp or just copy and paste them in a text file with file extension of .lsp to be able to add it to Startup suites from calling the command: APPLOAD then add it to contents list and in this case you need to reopen your drawing if it is the current one opened.

 

;;------------------------------------------------------;;
;;	Author : Tharwat Al Choufi			;;
;; website: https://autolispprograms.wordpress.com	;;
;;------------------------------------------------------;;
(vl-load-com)
(defun Start:Regen:Reactor nil
  (or *Start:Regen:Reactor*
      (setq *TH:Doc*              (vla-get-activedocument (vlax-get-acad-object))
            *Start:Regen:Reactor* (vlr-command-reactor
                                    "*Start:Regen:Reactor*"
                                    '((:vlr-commandended
                                       .
                                       Start:Regen:Function
                                      )
                                     )
                                  )
      )
  )
  (princ
    "\n < Start:Regen:Reactor > was successfully loaded.!"
  )
  (princ)
)

(defun Start:Regen:Function (non cmd)
  (if (wcmatch (strcase (car cmd) t) "*eattedit*")
    (vla-regen *TH:Doc* acAllViewports)
  )
)

(defun c:EndRegen nil
  (and *Start:Regen:Reactor*
       (progn (vlr-remove *Start:Regen:Reactor*)
              (setq *Start:Regen:Reactor* nil *TH:Doc* nil)
              (princ
                "\n < Start:Regen:Reactor > was successfully unloaded.!"
              )
       )
  )
  (princ)
)

(Start:Regen:Reactor)

 

Posted

You can add the regen command to your lisp say as last step, if your say using fields which often need a regen.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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