Reactor question

Discussion in 'AutoCAD' started by BillZ, Jun 3, 2004.

  1. BillZ

    BillZ Guest

    R2005 Vlisp:

    I have created an object reactor for a point object.
    I have a call back that prints to the screeen the coordinates if the point is moved.
    It appears that it prints to the screen multiple times if I move the point just once.
    Is this normal? Or am I doing something wrong.

    Command: m
    MOVE
    Select objects: 1 found

    Select objects:
    Specify base point or displacement: Specify second point of displacement or
    <use first point as displacement>:
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    The Location is (16.7883 2.37886 0.0)
    Command:

    Here is the callback function:

    (defun print-coordinates (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond ((vlax-property-available-p
    notifier-object
    "Coordinates"
    )
    (princ "\nThe Location is ")
    (princ (vlax-safearray->list (vlax-variant-value (vla-get-coordinates notifier-object))))
    )
    )
    )

    I created the object like this:

    (setq PointReactor (vlr-object-reactor (list Point1)
    "Point Reactor" '(:)vlr-modified . print-coordinates)))
    )

    TIA

    Bill
     
    BillZ, Jun 3, 2004
    #1
  2. BillZ

    BillZ Guest

    Whoops!

    Never mind.

    Had the creation line inside of a repeat loop.

    Darn Parens.

    Bill
     
    BillZ, Jun 3, 2004
    #2
  3. BillZ

    Rudy Tovar Guest

    Don't worry, everything has to be contained within a statement, not too
    perpetual based on our intellect we couldn't conclude any other logical
    assumption.

    ?*%#...! calculated :)-0....
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, Jun 3, 2004
    #3
  4. BillZ

    BillZ Guest

    Hey Rudy,
    While you're here,

    I made this reactor with 2 callbacks.

    (setq PointReactor (vlr-object-reactor (list Point1)
    "Point Reactor" '(:)vlr-modified . print-coordinates)
    :)vlr-erased . point-erased))
    )
    )
    I have 2 callback fuctions, one for each.

    But when I erase the point, the function for the point-erase works fine, but then the print coordinates tries to execute too so it gives me an error.

    Do I just have to trap all and any "what ifs"?

    I can get it to work if I add the vl-erased-p function.
    (defun print-coordinates (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond ((and (vlax-property-available-p
    notifier-object
    "Coordinates")
    (not (vlax-erased-p notifier-object))
    )
    (princ "\nThe Location is ")
    (princ (vlax-safearray->list (vlax-variant-value (vla-get-coordinates notifier-object))))
    )
    )
    )

    Just want to see if I'm on the right track.

    Bill
     
    BillZ, Jun 3, 2004
    #4
  5. BillZ

    Rudy Tovar Guest

    Although I do play around a bit with the editor reactor, I've not with
    object, or persistent reactor. That would be better answered by someone
    else. Luis E. or someone else perhaps. I'd like to mention Michael, but I
    don't think he's really done any...well maybe...

    If I but my mind to it I could figure it out, but I'm kinda in the middle of
    something.

    Sorry...


    but then the print coordinates tries to execute too so it gives me an error.
    (vla-get-coordinates notifier-object))))
     
    Rudy Tovar, Jun 3, 2004
    #5
  6. BillZ

    BillZ Guest

    Thanks Rudy,
    For being honest.

    Anyone give an example of an object reactor with multiple callbacks?


    Bill
     
    BillZ, Jun 3, 2004
    #6
  7. BillZ

    Mark Propst Guest

    i'm guessing that erasure counts as modification also?
    so your test for erasure is probably in the right direction
     
    Mark Propst, Jun 3, 2004
    #7
  8. BillZ

    BillZ Guest

    I'm guessing that erasure counts as modification also?

    Thanks Mark,
    I'm begining to to see that.

    My first mistake was thinking that this would be easy.
    It doesn't seem to make any difference if I make one or two reactors, it must count as a "mod".

    Bill
     
    BillZ, Jun 3, 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.