Author Topic: reactor linking objects  (Read 2715 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7526
reactor linking objects
« on: April 29, 2005, 05:04:03 PM »
I was parusing the help file and saw reactors. My question is, how do I get an object to react when another object is modified? Example:

text is linked to object with area when area changes text updates to new area value. I've seen a vlx that does this but wanted to know how it works.

Here is my feeble attempt:

Code: [Select]
(defun c:react (/)

  (defun print-radius (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond
      (
       (vlax-property-available-p
notifier-object
"Area"
       )
       (princ "\n The area is ")
       (princ (vla-get-area notifier-object))
       (princ)
      )
    )
  )

  (defun print-text (notifier-object reactor-object parameter-list)
    (vl-load-com)
    (cond
      (
     (setq x (vlax-property-available-p
notifier-object
"TextString"
       ))
(vla-put-TextString obj  x)
      )
    )
  )

  (setq myCircle (car (entsel)))
  (setq obj (vlax-ename->vla-object myCircle))
  (setq circleReactor
(vlr-object-reactor
  (list obj)
  "Circle Reactor"
  '((:vlr-modified . print-radius))
)
  )
  (princ)

  (setq mytext (car (entsel)))
  (setq obj (vlax-ename->vla-object mytext))
  (setq textReactor
(vlr-object-reactor
  (list obj)
  "Text Reactor"
  '((:vlr-modified . print-text))
)
  )
  (princ)
)


Thanks for your help.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

SMadsen

  • Guest
reactor linking objects
« Reply #1 on: April 30, 2005, 11:41:34 AM »
Some quick ideas:
XData: Have the area object refer to a text object by handle (a 1005 group).
Dictionary: Maintain arrays of referencing objects as XRecords (just like groups do it).
The object reactor itself: Use the data field of the reactor to refer to a text object.
Groups: Self-explanatory.

In any case, make sure that you verify the referenced objects before using them. You don't want an error due to handling non-existing objects during a reactor callback. Also, AUDIT has a problem with handles in 1005 groups if they are lost.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
reactor linking objects
« Reply #2 on: April 30, 2005, 12:24:25 PM »
Good advice Stig. If I'm not mistaken you can set the 1005 group data to "0" for objects that have gone to hades and audit won't balk.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Crank

  • Water Moccasin
  • Posts: 1503
reactor linking objects
« Reply #3 on: May 01, 2005, 07:02:50 AM »
It's a nice exercise...

But if you only need a linked text to display the area, then you can better use a field to do just that.
Vault Professional 2023     +     AEC Collection

ronjonp

  • Needs a day job
  • Posts: 7526
reactor linking objects
« Reply #4 on: May 02, 2005, 09:15:57 AM »
Quote
then you can better use a field to do just that.


That is true...but then the field will only work in Acad 2005+.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC