Author Topic: help:what's wrong with these two text reactor  (Read 3224 times)

0 Members and 1 Guest are viewing this topic.

haibinpro

  • Newt
  • Posts: 52
help:what's wrong with these two text reactor
« on: August 01, 2014, 04:39:54 AM »
textreactor.lsp
changge text1 can make text2 to change it's content to text1's,but
changge text2 cannot make text1's content change,why?
see the attach  gif pic

http://www.theswamp.org/index.php?topic=47524.0
Note that (vlr-data reactor) does not point to the text object.
if the reson is this,why change text1 can make text2 change.



textreactor2.lsp
just unnote the check block to give more check ,but after this change.
neither changge text1 or text2 can make the other text's conten change.
why?
« Last Edit: August 01, 2014, 04:43:10 AM by haibinpro »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: help:what's wrong with these two text reactor
« Reply #1 on: August 01, 2014, 05:47:01 AM »
As far as I can tell in this regard .

The vlr-object-reactor function would hold a list of vla-objects as *owners* and there must be ONLY one object as *data* so your modification that attached lisp is correct .  ;-)

http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6797.htm

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: help:what's wrong with these two text reactor
« Reply #2 on: August 01, 2014, 08:32:08 AM »
@ haibinpro:
I think your ex:update* functions have too many conditions. If I revise them the code works.
Note: I use BricsCAD.

It may be wise to add a global variable *updateInProgressP* to avoid 'cyclic' behavior (because A has changed B also changes, because B has changed A also changes, because A has changed B also changes...). But in my tests this does not seem to be required (if B has changed A is not write-enabled).

Code: [Select]
(defun ex:update-text1-for-text2 ( VLA-Text1 VLA-Text2 / strtext2 )
  (if
    (and
      (vlax-write-enabled-p VLA-Text1)
      (vlax-read-enabled-p VLA-Text2)
      (setq strtext2 (vla-get-textstring VLA-Text2))
    )
    (vla-put-textstring VLA-Text1 strtext2)
  )
  (princ)
)

(defun ex:update-text2-for-text1 ( VLA-Text2 VLA-Text1 / strtext1 )
  (if
    (and
      (vlax-write-enabled-p VLA-Text2)
      (vlax-read-enabled-p VLA-Text1)
      (setq strtext1 (vla-get-textstring VLA-Text1))
    )
    (vla-put-textstring VLA-Text2 strtext1)
  )
  (princ)
)

haibinpro

  • Newt
  • Posts: 52
Re: help:what's wrong with these two text reactor
« Reply #3 on: August 06, 2014, 01:20:47 AM »
As far as I can tell in this regard .

The vlr-object-reactor function would hold a list of vla-objects as *owners* and there must be ONLY one object as *data* so your modification that attached lisp is correct .  ;-)

http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6797.htm
cann't find "ONLY one object as *data*" at this page
does it mean that if it requiet "ONLY one object as *data*",there is no solution to get this sub done

haibinpro

  • Newt
  • Posts: 52
Re: help:what's wrong with these two text reactor
« Reply #4 on: August 06, 2014, 01:25:37 AM »
Thanks roy_043,
after change the code ref to you,It works perfectly.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: help:what's wrong with these two text reactor
« Reply #5 on: August 06, 2014, 04:49:37 AM »
As far as I can tell in this regard .

The vlr-object-reactor function would hold a list of vla-objects as *owners* and there must be ONLY one object as *data* so your modification that attached lisp is correct .  ;-)

http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6797.htm
cann't find "ONLY one object as *data*" at this page
does it mean that if it requiet "ONLY one object as *data*",there is no solution to get this sub done

Sorry for the confusion , but in all my searches for the object reactor I did not find any example shows that instead of data value they used a list of objects , or a string representing the object reactor .

have you ever used a list of objects instead of data in any of your codes ? eager to see an example .

Thanks

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: help:what's wrong with these two text reactor
« Reply #6 on: August 06, 2014, 06:33:03 PM »
in all my searches for the object reactor I did not find any example shows that instead of data value they used a list of objects, or a string representing the object reactor .

have you ever used a list of objects instead of data in any of your codes ? eager to see an example .

Here are two examples of storing a list of objects in the vlr-data of a reactor:

Linking Text & Circle
Linking Two Blocks

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: help:what's wrong with these two text reactor
« Reply #7 on: August 07, 2014, 04:37:43 AM »
Note that the original code in this topic uses single objects as reactor data. According to the docs reactor data can be 'any AutoLISP data' (see Tharwat's link).

@ Lee:
In the original code in this topic but also in your 'blocks sample' there is a (vlax-write-enabled-p) check immediately followed by a (not (vlax-erased-p)) check for the same object. But if an object is write-enabled it automatically follows that it is not erased. The (not (vlax-erased-p)) check is therefore superfluous I think. The same applies to (vlax-read-enabled-p).

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: help:what's wrong with these two text reactor
« Reply #8 on: August 07, 2014, 04:38:33 AM »
Here are two examples of storing a list of objects in the vlr-data of a reactor:

Linking Text & Circle
Linking Two Blocks

Thank you for these important lisps for reactors to learn .

And what I meant is something else in regard to my reply to the OP .
I was referring to the data parameter that is for the object reactor itself and not the vlr-data , for instance , can we have more than one vla-Text ? a list of texts I mean ?


Quote
(setq *ex:circle->text (vlr-object-reactor (list VLA-Circle) VLA-Text '((:vlr-modified . ex:circle->text))))

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: help:what's wrong with these two text reactor
« Reply #9 on: August 07, 2014, 01:30:10 PM »
...if an object is write-enabled it automatically follows that it is not erased. The (not (vlax-erased-p)) check is therefore superfluous I think. The same applies to (vlax-read-enabled-p).

Good catch roy - I hadn't realised that erased objects caused vlax-write-enabled-p to return nil, thank you.

And what I meant is something else in regard to my reply to the OP .

I was referring to the data parameter that is for the object reactor itself and not the vlr-data , for instance , can we have more than one vla-Text ? a list of texts I mean ?
Quote
(setq *ex:circle->text (vlr-object-reactor (list VLA-Circle) VLA-Text '((:vlr-modified . ex:circle->text))))

The data parameter for the object reactor is the data returned by vlr-data.

Therefore, yes - this data can be any AutoLISP data: a string, double, integer, object, entity, symbol or a list of any of these data types.