Author Topic: Dynamic Align Text to Curve { with Reactors }  (Read 57617 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #105 on: February 16, 2010, 11:39:06 AM »
When you say re-align
    * Align Object A with Curve A
    * Align Object B with Curve A
    * Re-Align Object B with Curve A

You mean dtremove & then dtcurve to re attach the text?

I'm not seeing the error here in ACAD 2000


Sorry, Re-Align without using DtRemove - i.e. When the prompt appears for text, you select the text that is already aligned, (apologies for not explaining that).

The program should remove the associated xData from the object when text is selected that is already aligned, so that the text may be 're-aligned' to another/ or the same object, but, in my case, the text object handles seem to switch at this point.

Luis has provided me with some modified code to try, so I shall see what he has come up with when I get a spare minute.  :-)
« Last Edit: February 16, 2010, 11:43:40 AM by Lee Mac »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #106 on: February 16, 2010, 02:22:40 PM »
The switch happens here:
Code: [Select]
 (defun putxdat (Obj App Data / ent xtype xval)

    (setq xtype
      (vlax-make-variant
        (vlax-safearray-fill
          (vlax-make-safearray
            vlax-vbInteger '(0 . 1)) '(1001 1000))))

    (setq xval
      (vlax-make-variant
        (vlax-safearray-fill
          (vlax-make-safearray
            vlax-vbVariant '(0 . 1)) (list App Data))))

    (vla-setXData Obj xtype xval)  ;  [color=red]<=====<<<  switches every other time[/color]
    )
   
    Haven't figured out why yet but here is a work around fix.
Code: [Select]
              (foreach obj (vlr-owners *DCurve$Align$Reactor*)

             (if (not (vlax-erased-p obj))
               (progn

                 (vla-GetXData obj app 'typ 'val)

                 (if (and typ val)
                   (progn
                     [color=red](setq tmp tObj)   ;   <-----------------------<<<  CAB added[/color]
                     (setq xDat (vl-remove-if-not
                                  (function
                                    (lambda (lst)
                                      (entget (handent (car lst)))))
                                  
                                  (read
                                    (vlax-variant-value
                                      (cadr
                                        (vlax-safearray->list val))))))
                    
                     (if (vl-position Hnd (mapcar (function car) xDat))
                       (progn
                         (putxDat obj app
                           (vl-prin1-to-string
                             (vl-remove-if
                               (function
                                 (lambda (x) (eq Hnd (car x)))) xDat)))))
    [color=red](if (not (equal tmp tobj)) (setq tobj tmp))  ;   <-----------------------<<<  CAB added[/color]
    )
  ))

               (vlr-owner-remove *DCurve$Align$Reactor* obj)))))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #107 on: February 16, 2010, 02:54:04 PM »
It happens because, inside of the modified callback it does modifications in arbitrary way to all the available texts, that were attached to the lines, and that portion of code what it does is trigger the modified event to all the notifiers (lines).

For example, if you place a debug message print out on the modified callbak for the notifier, you will noticed that it will show that there is a modification, when in reality is not required but was trigger.

That's why in my case I offer a way to simple do not run any reactor while doing the attachment of existing or new text's to the lines.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #108 on: February 16, 2010, 03:11:14 PM »
OK, I think I found it.
You did not localize tObj here.
Code: [Select]
(defun DTCurveUpd (Obj Reac Args
  /
  *error* ObjxDat typ val dist perp mirr para a#dif [color=red]tObj[/color])
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #109 on: February 16, 2010, 03:15:20 PM »
Ahhh!  I understand!

So when I modify the curve object by setting the xData for it, the tObj gets re-assigned.

So I suppose the best thing to do would be to stop the reactor from reacting during that part of the code (as you suggest Luis), or as you say CAB, use a temporary variable.

Thanks guys - it would have taken me ages to figure that out! Just shows you what a new pair of eyes does...

Lee

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #110 on: February 16, 2010, 03:23:34 PM »
OK, I think I found it.
You did not localize tObj here.
Code: [Select]
(defun DTCurveUpd (Obj Reac Args
  /
  *error* ObjxDat typ val dist perp mirr para a#dif [color=red]tObj[/color])

Yes, but the problem behind scenes is that every time the user does a selection of an existing attached text, it will trigger the reactor, and if they have a lot of text objects attached, guess that Lee, don't want that.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #111 on: February 16, 2010, 03:25:40 PM »
OK, I think I found it.
You did not localize tObj here.
Code: [Select]
(defun DTCurveUpd (Obj Reac Args
  /
  *error* ObjxDat typ val dist perp mirr para a#dif [color=red]tObj[/color])

Yes, but the problem behind scenes is that every time the user does a selection of an existing attached text, it will trigger the reactor, and if they have a lot of text objects attached, guess that Lee, don't want that.

True, although a dummy variable is an option it would be best to stop the reactor from triggering - as it is pointless if it does at this point.  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #112 on: February 16, 2010, 03:27:20 PM »
Lee,
Remove my temporary code and add the localized tObj shown in RED.
Yours is missing. I added that.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #113 on: February 16, 2010, 03:30:44 PM »
Yes, but the problem behind scenes is that every time the user does a selection of an existing attached text, it will trigger the reactor, and if they have a lot of text objects attached, guess that Lee, don't want that.

I don't see that happening.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #114 on: February 16, 2010, 03:33:12 PM »
The problem as I see it is that this code
Code: [Select]
(vla-setXData Obj xtype xval)  triggers the reactor & changes tObj which is not a local variable to that subroutine.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #115 on: February 16, 2010, 03:35:55 PM »
Yes, but the problem behind scenes is that every time the user does a selection of an existing attached text, it will trigger the reactor, and if they have a lot of text objects attached, guess that Lee, don't want that.

I don't see that happening.

Sorry, was talking about Lee original code, later today will tried with your corrections too.

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #116 on: February 16, 2010, 03:49:12 PM »
Lee,
Remove my temporary code and add the localized tObj shown in RED.
Yours is missing. I added that.


Will do Alan, but this would wipe the value of tObj when the reactor is triggered would it not?

I would rather just stop the reactor from firing at all if that is even possible  :|

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #117 on: February 16, 2010, 03:53:15 PM »

Will do Alan, but this would wipe the value of tObj when the reactor is triggered would it not?

I would rather just stop the reactor from firing at all if that is even possible  :|

haven't viewed the whole thread, but
the only way to stop a reactor foring is to remove it.
you can conditionally reduce the actions the event trap performs, but that is a different trip.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #118 on: February 16, 2010, 03:54:46 PM »
Lee,
Remove my temporary code and add the localized tObj shown in RED.
Yours is missing. I added that.


Will do Alan, but this would wipe the value of tObj when the reactor is triggered would it not?

I would rather just stop the reactor from firing at all if that is even possible  :|

AFAIK, vlr-owners - call with trigger the reactor - and that's what was happening - so it goes to whatever number of items connected to the notifier line to be updated - now without testing with CAB changes, the idea is to avoid the call or use of the reactor only when the line it is modified no?

I am out of a way to test lisp right now....

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #119 on: February 16, 2010, 03:55:24 PM »

Will do Alan, but this would wipe the value of tObj when the reactor is triggered would it not?

I would rather just stop the reactor from firing at all if that is even possible  :|

haven't viewed the whole thread, but
the only way to stop a reactor foring is to remove it.
you can conditionally reduce the actions the event trap performs, but that is a different trip.

Ok thanks for your advice Kerry - appreciated.  :-)

How about if I set a flag when the user is in the main function, and test for the flag in the Callback function - this seems like the easiest way to go  :-)