Author Topic: Reactor...  (Read 7347 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Reactor...
« Reply #15 on: March 01, 2005, 10:48:59 AM »
Quote from: SMadsen
Se7en, the COMMAND is not within a callback so it's perfectly legal.
...
When you get it working, I hope you are aware of the fact that the way it is written, it will add reactors each time C:HTZ is called (which can become very unpleasant).


The point is that you shouldnt use command or setvar in reactor apps at all untill you KNOW how/why/when you can use them. The fact that you can in certin circimstances is irrelevent to (s)he trying to learn reacotors. First they must learn why/what their code is doing before they can start learning the loop holes.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Reactor...
« Reply #16 on: March 01, 2005, 10:53:02 AM »
Aye Sir!

:P

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Reactor...
« Reply #17 on: March 01, 2005, 11:12:09 AM »
Im sorry if i sounded gruff in my post.

I think it would be best if you use Pseudo code to layout your reactors. Cause then you can see potential disasters.  Creating a reactor everytime a command is called is not a really good idea. ...you have to be carefull when you use reactors. They can get away from ya real fast.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Reactor...
« Reply #18 on: March 01, 2005, 11:17:52 AM »
A sure way to create a house of cards is to use reactors gratuitously. We use them VERY sparingly.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #19 on: March 01, 2005, 01:34:37 PM »
ok...so if i understand...
can i modify the code like this..


(defun c:HTz ()
 (if (and (not var1) (CC_find_env));;detect if some variable is set
   (progn    
  (SDC_readSfile);;read other variables
  (setq BC1r T11r
           BC1 T11
  );;redefine some variables
  (loadreactortype);;<---HERE LOAD REACTOR NOT WORKING
);;progn
);;if

(command "_DTEXT")
);;end HTz
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun loadreactortype ()
(setq var1 T)
;;(alert "Reactor loaded")
(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))
(vlr-command-reactor nil '((:vlr-commandFailed . failedCommand)))
)

But not seam to work... :roll:
Keep smile...

SMadsen

  • Guest
Reactor...
« Reply #20 on: March 01, 2005, 02:44:20 PM »
Setting a flag is one way to go about it, yes. If being precarious, which we all tend to be at times, it wouldn't necessarily mean that the reactors were actually created, though.

Personally, I would use the return value from VLR-COMMAND-REACTOR to tell me directly about the success of the function (in this particular case all the return values).

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #21 on: March 01, 2005, 03:27:13 PM »
SMaden..

I'm not sure if I really understand...
could you explain a little more ?
Keep smile...

SMadsen

  • Guest
Reactor...
« Reply #22 on: March 01, 2005, 05:00:29 PM »
It's pretty much explained in the thread that Serge linked to. Did you read the comments in the code?

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #23 on: March 02, 2005, 10:28:11 AM »
Quote from: SMadsen
It's pretty much explained in the thread that Serge linked to. Did you read the comments in the code?


Ok.. I've made some modification in my routine...and it work just fine with 2002 and 2004.

thanks all..

Now I need to know how to unload the reactor without closing the drawing..

any idea ?
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #24 on: March 02, 2005, 10:41:56 AM »
ok sorry...i just find it !!

(vlr-remove-all) :oops:
Keep smile...

SMadsen

  • Guest
Reactor...
« Reply #25 on: March 02, 2005, 10:55:53 AM »
I'm glad you got it working, Andrea.

Just in case you forgot to do this: If you are depending on recreation of the reactor after having killed it and you are maintaining a global variable that points to it then set the global to nil when destroying it.
Code: [Select]

;; if you are doing this to create the reactor:
...
  (if (not *my-reactor*)
    (setq *my-reactor* (vlr-command-reactor .... etc..)
  )
...

;; then do this when destroying it:
...
  (vlr-remove-all)
  (setq *my-reactor* nil)
...


Of course, if you have multiple reactors running, you can also kill the specific one with (vlr-remove *my-reactor*)

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #26 on: March 02, 2005, 09:51:52 PM »
thanks SM I appreciate..
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #27 on: March 03, 2005, 05:53:30 PM »
I use this...



(vlr-remove-all :vlr-command-reactor)


is this ok ?
Keep smile...

SMadsen

  • Guest
Reactor...
« Reply #28 on: March 03, 2005, 06:10:39 PM »
That would be correct if you want to kill all command reactors, yes.