Reactor on block attribute changes

Discussion in 'AutoCAD' started by Koistya `Navin \(TechProject\), Mar 23, 2005.

  1. Maybe someone does know a few examples of how to implement it. For ex.: a
    block with 2 attributes. When first attribute of the block is changed, the
    second attribute is automatically changes according to the value of the
    first attribute.
     
    Koistya `Navin \(TechProject\), Mar 23, 2005
    #1
  2. I mean something like..

    (vl-load-com)

    (vlr-editor-reactor
    nil
    '(:)vlr-commandEnded . editor-issue))
    )

    (defun editor-issue (f v / val)
    (setq val (strcase (car v)))
    (princ val)

    (if (= val "EATTEDIT")
    (progn
    ; the action function goes here
    )
    )
    (princ)
    )
     
    Koistya `Navin \(TechProject\), Mar 24, 2005
    #2
  3. Ok, reactor isn't a prob. But how get access to the modified block entity?
     
    Koistya `Navin \(TechProject\), Mar 24, 2005
    #3
  4. I would do something like this:

    1. Have one object reactor using the modified event and inside make a list of the modified objects.

    2. Have a second editor reactor using the commandEnded event and in there use the list with the modified objects and do the updates.
     
    Luis Esquivel, Mar 24, 2005
    #4
  5. Sounds like a plan ;-) But maybe there exists more smoothly way... For
    example, when vlr-commandEnded snaps into action, another vla- function get
    selected object, and it assumed that this object IS required block. What do
    you think about it?
     
    Koistya `Navin \(TechProject\), Mar 24, 2005
    #5
  6. Let me write some code... sample.... I'll be back

    LE
     
    Luis Esquivel, Mar 24, 2005
    #6
  7. Okay.... here is quick code sample, create first a block with two attributes
    and have a look if that is close of what you were trying to accomplish.....
    have fun

    LE

    (vl-load-com)

    (defun commandended
    (reactor params / atts att1 att2 text_att1 text_att2)
    (if modified_list
    (foreach blk modified_list
    (setq atts
    (reverse (vlax-safearray->list
    (vlax-variant-value (vla-getattributes blk))))
    att1 (car atts)
    att2 (cadr atts)
    text_att1 (vla-get-textstring att1)
    text_att2 (vla-get-textstring att2))
    (if (/= text_att2 text_att1)
    (vla-put-textstring att1 (vla-get-textstring att2)))))
    (setq modified_list nil))

    (defun subobjmodified (owner reactor params)
    (if (and (not (wcmatch (getvar "cmdnames") "UNDO,U,REDO,OOPS"))
    (not (vl-position owner modified_list)))
    (setq modified_list (cons owner modified_list))))

    (defun C:TEST (/ obj obj_reactor)
    (setq obj (vlax-ename->vla-object
    (car (entsel "\nSelect block with two attributes: "))))

    (if (not editor_reactor)
    (setq editor_reactor
    (vlr-editor-reactor
    "editor"
    '(:)vlr-commandended . commandended)))))

    (setq obj_reactor
    (vlr-object-reactor
    (list obj)
    "obj"
    '(:)vlr-subobjmodified . subobjmodified))))
    (princ))

    (princ)
     
    Luis Esquivel, Mar 24, 2005
    #7
  8. Luis, you are the man! Thanks in advanced.
     
    Koistya `Navin \(TechProject\), Mar 25, 2005
    #8
  9. Koistya `Navin \(TechProject\)

    deger Guest

    Mr. luis.
    When the editor reactor change the attribute of block, other object
    reactor will work certainly. Would these reactor will be launched in
    sequence? How to do? Can we cancel the object reactor in editor
    reactor?
    Can we change the block defined in editor?
    Thanks
     
    deger, Mar 25, 2005
    #9
  10. One more question... How do you think whether it is possible to make custom
    replacement for ACAD’s “Advanced Attribute Editor” in clean Visual LISP, I
    mean without ObjectARX programming? Maybe someone already came across
    analogous solution…
     
    Koistya `Navin \(TechProject\), Mar 25, 2005
    #10
  11. Will try to clarify.. I need this 'custom block's attribute editor’ to be
    turned on in interaction with certain adjusted block object (maybe chosen by
    name or specific parameters). So, when users double-click on this block,
    ‘custom attribute editor’ window should appear and original ‘Advanced
    Attribute Editor’ should be damped down. Any ideas?
     
    Koistya `Navin \(TechProject\), Mar 25, 2005
    #11
  12. Would these reactor will be launched in
    Not possible [according to all the code I have done with reactors]

    Yes but I like to do it as my sample.
     
    Luis Esquivel, Mar 25, 2005
    #12
  13. Yes that is possible, do a search for mouse reactor samples out there, I have done it as many other masters on this.

    Google will be your guide.... I hope.

    LE.
     
    Luis Esquivel, Mar 25, 2005
    #13
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.