Reactor labels

Discussion in 'AutoCAD' started by Jon, May 6, 2004.

  1. Jon

    Jon Guest

    I am about to modify a routine I have that labels lines/polylines/arcs with
    bearing and distances. I am going to make the labels dynamic so that if the
    line is alteres, the label is realigned and the text value amended. I was
    going to attached the handles of the text labels to the line as extended
    data so that I can identify them when the reactor for the line kicks in. Is
    this the only way to link the line and the text, or is there another method
    associated with reactors where I can say which entities are affected when
    the reactor is initiated?

    Jon Rasmussen

    My code for investigating Reactors:

    (defun c:brdr ()
    ;attached reactor to line
    (setq line (car (entsel "\nSelect Line ")))
    (setq linereactor (vlr-object-reactor
    (list (vlax-ename->vla-object line))
    "Line Reactor" '(:)vlr-modified . updatebrgdst))
    ))
    )
    (defun updatebrgdst (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond
    (
    (vlax-property-available-p
    notifier-object
    "length"
    )
    (princ "The length is ")
    (princ (vla-get-length notifier-object))
    )
    )
    (cond
    (
    (vlax-property-available-p
    notifier-object
    "angle"
    )
    (princ "The angle is ")
    (princ (vla-get-angle notifier-object))
    )
    )
    (princ)
    )
     
    Jon, May 6, 2004
    #1
  2. Jon

    Vaidas Guest

    hello,

    Alternatively you can store related object in parameter-list of linereactor. Access it using (vlr-data linereactor).

    regards,
    Vaidas Guogis
    www.kitox.com
     
    Vaidas, May 6, 2004
    #2
  3. Jon

    Jürg Menzi Guest

    Vaidas
    This is not recommendable...
    The Xdata is necessary to 'restore' the object reactors on startup of saved
    drawings (except persistent reactors).

    Cheers
     
    Jürg Menzi, May 6, 2004
    #3
  4. Jon

    Vaidas Guest

    The Xdata is necessary to 'restore' the object reactors on startup of saved
    drawings (except persistent reactors).

    Of course. I'm using both methods and persistent reactors too. Xdata requires more coding to restore relations, but it looks better to me. However, the question was about alternative.

    regards,
    Vaidas Guogis
    www.kitox.com
     
    Vaidas, May 6, 2004
    #4
  5. If the line and text are both "owners" of the reactor, you can step through
    the owner list to find the text object and then modify it.

    Creating the reactor:

    (setq line_reactor
    (vlr-object-reactor
    (list vlent vtent) ; note both the line (vlent) and text (vtent) are
    owners...
    "Line_Reactor"
    '(:)vlr-modified . line_reaction)
    :)vlr-erased . reactor_obj_erased))
    )

    )
    (vlr-pers line_reactor) ; make it persistent

    and in the reaction event (nname is the name of the notifier object and nobj
    is the notifier object type):

    (foreach xbj (print (vlr-owners reactorlist))
    (setq oname (vlax-vla-object->ename xbj))
    (if oname
    (progn
    (if (= (car (assoc 0 (entget oname))) "TEXT")
    (if (= nobj "LINE") (text_update oname nname)))
    )
    )
    )
     
    Allen Johnson, May 6, 2004
    #5
  6. Jon

    Jon Guest

    Thank you everyone. Allen's solution looks like the way forward. I didn't
    realise that the reactor could be tied to more than one object. The note
    about persistent reactors is much appreciated also.

    Thank you.

    Jon Rasmussen
     
    Jon, May 6, 2004
    #6
  7. Jon

    Jon Guest

    Another question, if I may trouble you further:
    How do you determine if the object already has a reactor, and subsequently
    remove the reactor so I can replace it with a new reference.
    If I re-label the line, I need to re-associate the text to the reactor, and
    the label text has xdata for how the label was derived (roundings and
    alignment). So if the line is re-labelled, I would like to remove the
    previous reactor.

    I will look into vlr-owner-remove 'cause it sounds promising.

    Thanks again,

    Jon Rasmussen
     
    Jon, May 7, 2004
    #7
  8. Jon

    Jon Guest

    here are two of my routines that i use hth:
    hth - what a lovely understatement

    Thank you Luis

    Jon
     
    Jon, May 7, 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.