Jump to content

Question about Reactors


Grrr

Recommended Posts

Hi guys,

 

I didn't found anywhere similar information about a reactor questions that keeps me curious.

So my questions are:

 

*Callback question:

Is it possible to run a lisp command definition through a reactor as a callback?

For example run C:test for a certain event.

 

*Event question:

Is it possible to re-run that command (C:test) like a loop with delay for example 0.5 seconds? (I don't know what the result might be - maybe AutoCAD will crash).

But that means no event will be included? Or if its important to have one: get it from a certain value of "CDATE" variable.

 

*Example callbacks for this kind of event:

-Print a tip from a list, from a lisp like this in every 15 minutes:

 

(defun-q c:test ( / lst )

   (setq lst '( "[#1] Tip Number 1."
	 "[#2] Tip Number 2."
	 "[#3] Tip Number 3."
	 "[#4] Tip Number 4."
	 "[#5] Tip Number 5."
	 "[#6] Tip Number 6."
       )
   )
   (setq c:test (vl-list* '( / lst ) (list 'setq 'lst (list 'quote (append (cdr lst) (list (car lst))))) (cddr c:test))) 
   (setq storedvalue (car lst))
   (princ (strcat "\n" storedvalue " "  ))
   (princ)
)	

-Or the lisps performs some checks in the drawing: for example is there a block/layer that needs to be purged,

Is there a selection made - if it is then invoke properties, if its not then closeproperties (Lee Mac did reactor about this one, but I'm still curious for that alternate way).

Link to comment
Share on other sites

Hi guys,

 

I didn't found anywhere similar information about a reactor questions that keeps me curious.

So my questions are:

 

*Callback question:

Is it possible to run a lisp command definition through a reactor as a callback?

For example run C:test for a certain event.

 

*Event question:

Is it possible to re-run that command (C:test) like a loop with delay for example 0.5 seconds? (I don't know what the result might be - maybe AutoCAD will crash).

But that means no event will be included? Or if its important to have one: get it from a certain value of "CDATE" variable.

 

*Example callbacks for this kind of event:

-Print a tip from a list, from a lisp like this in every 15 minutes:

 

(defun-q c:test ( / lst )

   (setq lst '( "[#1] Tip Number 1."
        "[#2] Tip Number 2."
        "[#3] Tip Number 3."
        "[#4] Tip Number 4."
        "[#5] Tip Number 5."
        "[#6] Tip Number 6."
          )
   )
   (setq c:test (vl-list* '( / lst ) (list 'setq 'lst (list 'quote (append (cdr lst) (list (car lst))))) (cddr c:test))) 
   (setq storedvalue (car lst))
   (princ (strcat "\n" storedvalue " "  ))
   (princ)
)    

-Or the lisps performs some checks in the drawing: for example is there a block/layer that needs to be purged,

Is there a selection made - if it is then invoke properties, if its not then closeproperties (Lee Mac did reactor about this one, but I'm still curious for that alternate way).

If I understand your question, yes you can a LISP routine for a certain event, just make use of vla-sendcommand. To delay the command for 5 seconds, make use of the delay command (use vla-sendcommand) with an amount of 5000.
Link to comment
Share on other sites

Hi broncos15,

 

But does that mean that vla-sendcommand will work for lisp command definitions?

I know that it would work with the standard autocad commands, as I have this example from LM:

(autoprops:sendcommand "_.properties ")

(defun autoprops:sendcommand ( com )
   (eval
       (list 'defun 'autoprops:sendcommand '( com )
           (list 'vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) 'com)
       )
   )
   (autoprops:sendcommand com)
)

But will this work the same way ?:

(autoprops:sendcommand "_.test ")

 

I haven't heard of the delay command, but you get the idea about what type of reactor I'm asking about

(to run c:test with a delay, and c:test performs its checks for the drawing).

Link to comment
Share on other sites

Yes you could you use it just like that. The reference that I have used is http://www.afralisp.net/archive/methods/list/sendcommand_method.htm. And yeah I understand. You want to put the delay command at the beginning of the reactor, before you did everything else. That way you could delay it whatever amount of time you want and then have the reactor do whatever you wanted after that.

Link to comment
Share on other sites

Thanks, now I know that those reactor "ideas" of mine are possible.

However I'm still amazed why such type of an delay reactor is so unpopular (accordingly to my google research).

Perhaps a possible reason might be, because it would drain the CPU by continiously checking the event.

Link to comment
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
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...