Reactor not reacting!

Discussion in 'AutoCAD' started by kemp, Jan 8, 2004.

  1. kemp

    kemp Guest

    Hello - I have a reactor function below that only seems to work halfway. I
    have two entities being passed to the reactor, a line and a block. The
    reactor should adjust the line based on changes to either the line or the
    block. The reactor works fine if i move the block, but when moving the line
    it runs through the process and the changes are not made. It doesn't modify
    the line (entmod ENL) even though when i print out the values of ENL the
    values are correct.

    Hopefully someone out there can explain to me why this is happening. As far
    as I am concerned it should work, but alas, I am no expert...

    (defun adjustLine (notifier-object
    reactor-object
    parameter-list /
    object-list
    vla-object
    EN EL ENL p1 p2)
    ;;Get list of objects
    (setq object-list (vlr-owners reactor-object))
    ;;Loop through each object in list
    (foreach vla-object object-list
    ;;Convert object reference to AutoLISP style
    (setq EN (vlax-vla-object->ename vla-object)
    EL (entget EN))
    (cond ;;what type of entity is it?
    ((= (cdr (assoc 0 EL)) "LINE");;Is the entity a line?
    (setq ENL EL);;save entity list of line
    (setq p2 (cdr (assoc 11 ENL))));;line cond
    ('T
    ;;Otherwise it is the block so get the insertion point
    (setq p1 (vlax-safearray->list
    (vlax-variant-value
    (vla-get-insertionpoint vla-object)
    ))));;block cond );;cond );;foreach
    ;;Find point p1 will be moved to
    (setq p3 (polar p1
    (angle p1 p2)
    (* 0.20828125 scale)))
    (princ "\nENL: ")(princ ENL) ;<---shows values before line is
    changed
    ;;replace values in entity list
    (setq ENL (subst (cons 10 p3)
    (assoc 10 ENL)
    ENL)
    ENL (subst (cons 11 p2)
    (assoc 11 ENL)
    ENL))
    (entmod ENL);;update the line ;<---only works when block is moved, why
    not line?
    (princ "\n\nENL: ")(princ ENL) ;<---shows correct values why isn't line
    moved here?
    (princ)
    )

    Thanks if anyone knows!
    kemp
     
    kemp, Jan 8, 2004
    #1
  2. kemp

    ECCAD Guest

    You may have to do (entupd ENL) following the:
    (entmod ENL);;update ...

    Just guessing.
    Or regen ?
    Bob
     
    ECCAD, Jan 8, 2004
    #2
  3. kemp

    kemp Guest

    I tried entupd and regen but get the same results. I do notice that if I
    change the line

    (entmod ENL)
    to
    (setq kikkoman (entmod ENL))(princ kikkoman)

    the result is nil only when i move the line. When i move the block it prints
    entity data like it is supposed to.

    Thanks for guessing, any more guesses? :)
     
    kemp, Jan 8, 2004
    #3
  4. kemp

    Dan Elkins Guest

    Review the Reactor Use Guidelines.

    They state:
    "... to access drawing objects, you must use ActiveX functions; entget and
    entmod are not allowed inside callback functions."

    -Dan
     
    Dan Elkins, Jan 9, 2004
    #4
  5. kemp

    kemp Guest

    I removed all entget or entmod refernces in favor of activeX functions, and
    still have exactly the same problem. See attached file for the entire lisp
    routine with changes.

    I replaced the entmod functions with vla-put-startpoint & vla-put-endpoint
    and now it will not complete the reactor function if the line is moved, but
    does fine if the block is moved. So in essense it works exactly as it did
    before....

    I hope someone can help figure it out! Thanks!

    kemp
     
    kemp, Jan 9, 2004
    #5
  6. kemp

    Dan Elkins Guest

    I didn't really look at your code in detail, but I did notice that you
    wern't updating the object. Found this in the docs:

    Note that changing an object's property may not immediately affect the
    display of the object in the AutoCAD drawing. AutoCAD delays property
    changes to allow you to change more than one property at a time. If you need
    to update the drawing window explicitly, issue the vla-update function:

    (vla-update object)Take note, that I haven't been doing any (v)lisp for a
    while, so I'm a little rusty.-Dan
     
    Dan Elkins, Jan 9, 2004
    #6
  7. kemp

    kemp Guest

    Thanks for the tip, I'll see what I can do with it.

    kemp
     
    kemp, Jan 9, 2004
    #7
  8. kemp

    kemp Guest

    I just read this: "The event causing an object to trigger a callback
    function may still be in
    progress and the object still in use by AutoCAD when the callback function
    is invoked." so I simply am not allowed to have the reactor change the line
    i moved to call it.

    This is my problem. Now I need to figure out the workaround. If I move a
    line that fires a reactor, can i create a new line and have it be associated
    with the reactor?
     
    kemp, Jan 9, 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.