TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Dan113 on March 16, 2017, 08:54:09 AM

Title: Command reactor
Post by: Dan113 on March 16, 2017, 08:54:09 AM
I am trying to modify an invisible attribute in a block. I am trying to do this using vlr-commandended but im unsure how to get the ENAME of the block on exiting either block editor or ref editor. Im new to reactors and struggling a little. All i need is the ename of the block but its driving me mad trying to work it out. Can anyone point me in the right direction?
Title: Re: Command reactor
Post by: Grrr1337 on March 16, 2017, 12:54:39 PM
I think that you have to use vlr-acdb-reactor with :vlr-ObjectModified event, so in the callback function you should get the block's ename as an argument.
But I'm also a reactor newbie so I'm not sure.
Perhaps elaborate more what reactor you currently use and what you're trying to achieve.
Title: Re: Command reactor
Post by: dgorsman on March 16, 2017, 12:58:51 PM
That's essentially correct - react to the database change by logging the entity that was modified.  Then in the command-ended reactor read the logged entity ID, disable the database reactor (so you don't loop), change it, then re-enable the database reactor.

Note that you can run into problems when entities can be direct-edited without issuing a command e.g. editing block attributes via the Properties panel.
Title: Re: Command reactor
Post by: Dan113 on March 17, 2017, 07:13:15 AM
Here is what i have so far, all im trying to do is add an invisible attribute to the block. Whether its been modified or not, its just an indication of modifications or potential modifications.

All im managing to get is the block record ename, im not entirely sure if its possible to add an attribute to that?

initial starting test code from a lee mac post

Code: [Select]
(defun c:test nil

  (if (not *react*)
    (setq *react*
      (vlr-command-reactor nil
        (list
          (cons :VLR-commandWillStart 'callback)
        )
      )
    )
    (progn
      (vlr-remove *react*)
      (setq *react* nil)
    )
  )

  (princ)
)

(defun callback ( reactor parameters )

  (cond
    ((or
       (= (car parameters) "BEDIT")
       (= (car parameters) "REFEDIT")
     )
     (alert
       (strcat
"Reactor: " (vl-prin1-to-string reactor)
"\nList: "    (vl-prin1-to-string parameters)
       )
     )
     (setq *dbreact*
      (vlr-acdb-reactor nil
        (list
          (cons :vlr-ObjectModified 'omcallback)
        )
      )
     )
     (setq *cereact*
      (vlr-command-reactor nil
        (list
          (cons :VLR-commandended 'cecallback)
        )
      )
     )
    )
    (t
     (princ
       (strcat
"\nNot block edit\n"
       )
     )
    )
  )

  (princ)
)
 
(defun omcallback ( reactor parameters )

  (setq obj-ename (cadr parameters))
  (vlr-remove *dbreact*)
  (setq *dbreact* nil)
)

(defun cecallback ( reactor parameters )

  (cond
    ((or
       (= (car parameters) "BCLOSE")
       (= (car parameters) "REFCLOSE")
     )
     (vlr-remove *cereact*)
     (setq *cereact* nil)
    )
  )

)