Author Topic: Reactor question  (Read 17963 times)

0 Members and 1 Guest are viewing this topic.

hunterxyz

  • Guest
Re: Reactor question
« Reply #60 on: July 23, 2007, 07:27:46 PM »
If said that is the selection “PLINE” the automatic production “TEXT” the thing and has the area value, when and carries on “PLINE” the thing “COPY”, but is connected the production automatically “TEXT” the thing, and the content is its area value, how should achieve the duplication the response movement?

Hoped that the moderator perhaps other masters may explain.
Thanks!

hunterxyz

  • Guest
Re: Reactor question
« Reply #61 on: July 23, 2007, 07:32:13 PM »
I hope not to derail this thread by posting an alternate solution.

I  notice you are using the Object Reactor to store the area and the handle of the text in an extension dictionary of the polyline object and then creating a Command Reactor that is doing the modification to the text when the :vlr-CommandEnded callback fires.  You can do this all at once with just the Object Reactor on the Polyline object by storing the area of the Polyline and the handle of the text in the client data of the reactor object and the modifying the text when the :vlr-ObjectClosed callback fires.

You can set and retreive this data using the VLR-Data-Set and VLR-Data functions respectivelly, and you can also use it to store a flag for what to do when the object is closed, to handel the polyline getting deleted.

When you create your reactor, store the initial data and have it react to all situations:
Code: [Select]
(VLR-Object-Reactor
 (List (VLAX-EName->VLA-Object PolylineObject))
 (List '(0 . 0) ;modify flag
        (Cons 1 PolylineArea ) ;area of polyline
        (Cons 2 TextObjectHandle) ;handle of the text object
 )
 '((:vlr-Cancelled . Pline_Cancelled-Callback )
   (:vlr-Modified . Pline_Modified-Callback )
   (:vlr-Copied . Pline_Copied-Callback )
   (:vlr-Erased . Pline_Erased-Callback)
   (:vlr-UnErased . Pline_UnErased-Callback )
   (:vlr-ObjectClosed . Pline_ObjectClosed-Callback )
  )
)

Put (vlr-trace-reaction) in all of the callbacks and watch the order in whice they come down.  When the object is modified :vlr-Modified fires then :vlr-ObjectClosed.  When the object is erased :vlr-Modified fires, then :vlr-Erased, then :vlr-ObjectClosed fires.
You cannot rely on the order in which the callbacks will fire, especially when modifying multiple objects at once.  The :vlr-ObjectClosed will always fire when the object is closed for editing.  You use the other callbacks to over-write the modify flag in the client data of the reactor object and then retreive it to determine what the Pline_ObjectClosed-Callback function will do.  The Pline_Modified-Callback function will store the area of the polyline into the 1 dotted-pair of the association list.

If you want to go down this tangent, I can post lots of code snipettes, since I just finished writing a reactor that linked a lable with an object and maintained it when the object changed.  It also had to take into account not only when the object was erased and brought back with the OOPS or Undo Commands (:vlr-UnErased), but also when the object and lable were copied and the new label had to become linked to the new object.


Ask you are
 '((:vlr-Cancelled . Pline_Cancelled-Callback )
   (:vlr-Modified . Pline_Modified-Callback )
   (:vlr-Copied . Pline_Copied-Callback )
   (:vlr-Erased . Pline_Erased-Callback)
   (:vlr-UnErased . Pline_UnErased-Callback )
   (:vlr-ObjectClosed . Pline_ObjectClosed-Callback )
  )
connected procedure in where?