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

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« on: February 28, 2005, 12:09:59 PM »
Hi,

I'm trying understand reactor...

does anyone can give me some samples with the

vlr-commandWillStart
vlr-commandEnded
vlr-commandCancelled

??

thanks.
Keep smile...

nivuahc

  • Guest
Reactor...
« Reply #1 on: February 28, 2005, 12:25:43 PM »
Sure Andrea, be glad to!

Check out this link. It has quite a bit of really great information about reactors and how they work.

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #2 on: February 28, 2005, 02:58:20 PM »
ok...I have made this...

for test..
but the alert box apear 4 times...WHY ???





Code: [Select]
(vl-load-com)

;*******************************************************
(vlr-command-reactor
nil '((:vlr-commandWillStart . startCommand))
)

(defun startCommand (calling-reactor startcommandInfo /)

  ;thecommandstart drgName newname)

(setq thecommandstart (nth 0 startcommandInfo))

(if (= thecommandstart "PLINE")
 (progn
 (alert "The PLINE command was activated")
 (setq thecommandstart NIL)
 )
 (setq thecommandstart NIL)
 )
))


any HELP ??
Keep smile...

Serge J. Gianolla

  • Guest
Reactor...
« Reply #3 on: February 28, 2005, 05:12:52 PM »
Tiens, au lieu de te casser la tete; regarde ici
http://www.theswamp.org/phpBB2/viewtopic.php?t=2745&highlight=reactors

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #4 on: February 28, 2005, 07:20:55 PM »
Quote from: Serge J. Gianolla
Tiens, au lieu de te casser la tete; regarde ici
http://www.theswamp.org/phpBB2/viewtopic.php?t=2745&highlight=reactors


Serge !!  Bon sens,,  j'étais en train de t'écrire quand j'ai vu ton post..
depuis le temp que j'essai de trouver le pourquoi du comment.....ouf !!
Je ne sais plus comment t'appeler maintenant....

Proffesseur, Maître,....ou tout simplement Dieu !! 8)


un GROS merci....
Keep smile...

nivuahc

  • Guest
Reactor...
« Reply #5 on: February 28, 2005, 07:32:08 PM »
Wow, Andrea, that's an awful lot of praise you threw out there!

Should I have answered you in French?

Serge J. Gianolla

  • Guest
Reactor...
« Reply #6 on: February 28, 2005, 09:38:16 PM »
Quote
Should I have answered you in French?

Ne soyons pas chauvin, nivuahc! :D  :lol:
Glad you enjoyed the other link. Reactors are great... when they behave!!! :oops:

Serge J. Gianolla

  • Guest
Reactor...
« Reply #7 on: February 28, 2005, 09:48:27 PM »
Quote
Je ne sais plus comment t'appeler maintenant....

Pas besoin de m'appeler, je viens tout seul. <<Marrant non! :P

daron

  • Guest
Reactor...
« Reply #8 on: February 28, 2005, 10:06:31 PM »
French??? You might try Italian, if you want them to understand it.

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #9 on: March 01, 2005, 09:15:31 AM »
Daron,....

ITALIAN
Parlo anche Italiano...e tù ?
in fatto...sono nato a Roma.

 8)


ENGLISH
ok now i've discover something..

The code work only with AutoCAD 2004 and Higher..
In 2002..this code is not reset back the layer..

WHY ?

FRENCH
Je ne sais pas trop pourquoi ce foutu code ne fonctionne pas bien en 2002
il ne retourne pas à la couche précédente.
Keep smile...

SMadsen

  • Guest
Reactor...
« Reply #10 on: March 01, 2005, 09:27:53 AM »
Hmmm, maybe I should start writing in Danish?

[sarcasm]But then I would probably not receive any help in an english speaking forum, would I now?[/sarcasm]

Andrea

  • Water Moccasin
  • Posts: 2372
Reactor...
« Reply #11 on: March 01, 2005, 09:33:50 AM »
ok...maybe to much work than i can't see..

but i have this code..to anable reactor...



Code: [Select]

(defun c:HTz ()
 (if (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 ()
;;(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)))
)



Also i have made tests with alertbox....and the alertbos is shown..
but the reactor is not active..

why ? :cry:  (i'm tired)
Keep smile...

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
Reactor...
« Reply #12 on: March 01, 2005, 09:54:39 AM »
Quit using "COMMAND" In reacor apps!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Reactor...
« Reply #13 on: March 01, 2005, 10:30:20 AM »
To add to 7's comment. While it's bad to use command in reactors, it's even worse to use a command line that errors out to user control and doesn't take control back. Autocad needs to have control in order to react.

SMadsen

  • Guest
Reactor...
« Reply #14 on: March 01, 2005, 10:40:42 AM »
Se7en, the COMMAND is not within a callback so it's perfectly legal.

Andrea, the code you posted gives no clue to the problem, except that CC_FIND_ENV probably returns nil so that LOADREACTORTYPE will never be called.

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

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.