Reactor help (first time trying it)

Discussion in 'AutoCAD' started by Jamie Myers, Dec 29, 2003.

  1. Jamie Myers

    Jamie Myers Guest

    As my first attempt using reactors. I've decided to do a routine for when a
    layout has been added or copied, then I can take the name and use it in my
    title block.

    I'm stuck not knowing where to start. I'm guessing that I need to set up a
    reactor straight up, but I'm not sure which one to use. I'm thinking that I
    should get one reactor for when the layout is added and one for when it is
    copied. Is vlr-acdb-reactor the right choice here for one of the things I
    want to accomplish? I'm just not sure which way to go about creating
    routines with reactors in them. With some help, I might be able to work my
    way through it. For starters, maybe a sample routine with the reactor I
    need so that I can start my research in the right spot. TIA to those who
    reply. But be warned, I will have a lot more questions before it's all said
    and done <g>.
     
    Jamie Myers, Dec 29, 2003
    #1
  2. Hi Jamie

    Just to get you started here is a little reactor routine that I cooked up for you.

    It doesn't modify your title block but it reacts to the creation of a layout.

    Load and run the acdbreactor routine and then create a layout.

    Peter Jamtgaard


    (defun C:ACDBReactor ()
    (setq rxnAppend (vlr-acdb-reactor nil '(:)vlr-objectAppended . ACDBAppend )))
    rxnCommand (vlr-command-reactor nil '(:)vlr-commandEnded . ACDBCommand)))
    )
    )
    (defun ACDBAppend (CALL CALLBACK)
    (setq blnACDBFlag nil

    objACDBLayout nil
    objSelection (vlax-ename->vla-object (cadr CALLBACK)))
    (if (= (vla-get-objectname objSelection)
    "AcDbLayout"
    )
    (setq blnACDBFlag 'T
    objACDBLayout objSelection
    )
    )
    )

    (defun ACDBCommand (CALL CALLBACK)
    (if (= blnACDBFLag 'T)
    (progn
    (print (vla-get-name objACDBLayout))
    (print "Manipulate your titleblock here.")
    (setq blnACDBFlag nil objACDBLayout nil)
    )
    )
    )
     
    Peter Jamtgaard, Dec 30, 2003
    #2
  3. Jamie Myers

    Jamie Myers Guest

    Well, after looking at this, I dunno if I'm ready to learn reactors or not, but I'll still try. Could you put some comments in showing what each line is doing? I'm having trouble understanding what's going on. Trying not to look a gift horse in the mouth, it really doesn't quite do what I thought it would. The reactor needs to fire when a layout's name has been changed. I had to rearranged it so that I can see it better and have added notes. Let me know how close I am. Maybe after I understand this, I might be able to manipulate it to do what I need. Also, is there a reason why you have used one routine to set off the other? Couldn't these two be combined into one?

    (defun C:ACDBReactor ()
    (setq rxnAppend (vlr-acdb-reactor nil '(:)vlr-objectAppended . ACDBAppend ))));If anything is added to the ACad DataBase, thenrun the sub-routine ACDBAppend
    (setq rxnCommand (vlr-command-reactor nil '(:)vlr-commandEnded . ACDBCommand))));whenever a command has ended, check to see if the flag has been set for the print sequence
    );end defun

    (defun ACDBAppend (CALL CALLBACK);routine to check to see if the appended object in the database is a layout
    (setq blnACDBFlag nil)
    (setq objACDBLayout nil)
    (setq objSelection (vlax-ename->vla-object (cadr CALLBACK)));*****I'm not understanding where the varible CALLBACK has been set at*****
    (if (= (vla-get-objectname objSelection) "AcDbLayout"); Checks to see if the object is a layout
    (setq blnACDBFlag 'T objACDBLayout objSelection); sets the flag for the command end sub-routine
    );end if
    );end defun

    (defun ACDBCommand (CALL CALLBACK);routine to check for the flag stating that the layout has been changed
    (if (= blnACDBFLag 'T);if flag has been set, then get the layout name and print message
    (progn
    (print (vla-get-name objACDBLayout));get layout name and print it
    (print "Manipulate your titleblock here.")
    (setq blnACDBFlag nil objACDBLayout nil);sets these variables to nil so that the reactors for these routines will not fire again.
    );end progn
    );end if
    );end defun


    Thanks for the help! I'm learning some of it now.
     
    Jamie Myers, Dec 31, 2003
    #3
  4. Jamie Myers

    Mark Propst Guest

    Jamie,
    There is a copious amount of information on reactors, how they're constructed, how they work, what to do and what not to do with them in the help files. Unfortunately it takes some time reading and in my case re-reading (many times) to digest it all. Then more time trying simple examples, then more time searching google for other discussions (of which there are hundreds) regarding the esoteric details of reactors that may be harder to find easily in the help files. I don't know if there are limits to Peter's time and generosity but it sounds to me like you may want to do a little "preparing of the ground" so that the extremely valuable seeds Peter has already generously sown for you, may take root and grow to bear fruit.

    one example:
    (setq objSelection (vlax-ename->vla-object (cadr CALLBACK)));*****I'm not understanding where the varible CALLBACK has been set at*****

    if you read the help files it will answer that question for you, and many others besides.
    And if you have already read them (i'm not assuming that you haven't) then re-read them many times and you will eventually see it.

    hth
    Happy new year
    Mark

    Well, after looking at this, I dunno if I'm ready to learn reactors or not, but I'll still try.
     
    Mark Propst, Dec 31, 2003
    #4
  5. Jamie Myers

    Jamie Myers Guest

    You know, I read through the help files and I was having trouble so I came here. Peter was kind enough to help me out and I was curious as how he got what he done. I learn better from example. His example got me on the right track, but I still have some questions. You see, he is a what is known as good person for his helping. You are not because you are no help at all. So please do eveyone a favor, if your not helping, DON'T REPLY!!!
     
    Jamie Myers, Dec 31, 2003
    #5
  6. Jamie Myers

    Tink Guest

    "Mark Propst" <nonentityatplanetkcdotcom> wrote in message
    Jamie,
    There is a copious amount of information on reactors, how they're constructed, how
    they work, what to do and what not to do with them in the help files.
    Unfortunately it takes some time reading and in my case re-reading (many times) to
    digest it all. Then more time trying simple examples, then more time searching
    google for other discussions (of which there are hundreds) regarding the esoteric
    details of reactors that may be harder to find easily in the help files. I don't
    know if there are limits to Peter's time and generosity but it sounds to me like
    you may want to do a little "preparing of the ground" so that the extremely
    valuable seeds Peter has already generously sown for you, may take root and grow
    to bear fruit.

    ***********************************************

    Mark,
    While I'm sure your intentions were honorable, you completely missed
    something.

    A.) Not everyone has the time to sit down and digest the help files. (Most people
    refer to that as a deadline)
    B.) The help files need some help themselves.
    C.) You aren't Jamie, and he isn't you.

    If you would like, I have a fire control weapons station sitting in my lab. I
    invite you to come on over, sit down and fire it up. I'll provide you with the
    tech manual (copious amounts of information in that book also) so that you can
    read up on how to operate it. Now, that being said, you can only have 8 hours to
    learn everything in the manual, sit down at the station and operate it like your
    an expert.


    Get the point yet?




    Tink.
     
    Tink, Dec 31, 2003
    #6
  7. Jamie Myers

    UserName Guest

    Now that's the way to get people to spend their time and energy creating free code for you.

    What a way to start the new year.
    You know, I read through the help files and I was having trouble so I came here. Peter was kind enough to help me out and I was curious as how he got what he done. I learn better from example. His example got me on the right track, but I still have some questions. You see, he is a what is known as good person for his helping. You are not because you are no help at all. So please do eveyone a favor, if your not helping, DON'T REPLY!!!
     
    UserName, Jan 2, 2004
    #7
  8. Jamie Myers

    UserName Guest

    Except he wants help but won't go to the time or trouble to read through the
    help files. Why should Peter (or anyone else) go to the trouble of helping
    someone who either won't or can't help himself, and then get snide about it.
     
    UserName, Jan 2, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.