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

0 Members and 1 Guest are viewing this topic.

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #90 on: February 15, 2010, 05:29:44 PM »
Hi Lee,

- Is even moving the other object too... unless this is by design
- Also, on my first try I typed a text and way after end changing to mtext, is that me? or is there that change on your code?

Need to become more familiar with your code, inorder to really help you, if I get a chance later today, will give it a try.


And yes is me.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #91 on: February 15, 2010, 05:50:19 PM »
Hi Lee,

- Is even moving the other object too... unless this is by design

No, this isn't by design - it's meant to re-align the text that you select  :|

Everything seems to be fine when aligning new text, it only seems to be when re-aligning  :-(

- Also, on my first try I typed a text and way after end changing to mtext, is that me? or is there that change on your code?

The user can either select text to align, or type new text. When typing new text, there is a setting at the top of the code that determines whether text or Mtext is created.

And yes is me.

Thought it was  :wink:

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #92 on: February 15, 2010, 06:12:18 PM »
- I am looking at your code now.

and on this line:
Code: [Select]
(vl-prin1-to-string
                             (vl-remove-if
                               (function
                                 (lambda (x) (eq Hnd (car x)))) xDat))

That sometimes return: "nil" and that it is saved.
In there with the (entget) you are trying to make sure that the handle is valid no?, that's why you recreate the xdata.

Code: [Select]
                 (vla-GetXData obj app 'typ 'val)

(print (vlax-safearray->list val))
;|
DTCURVE
Type or Select Text <TEXT1> :
Handle selected: 182
(#<variant 8 DTCURVE> #<variant 8 (("185" "181" 1.0 1.5708 0.0 6.44746 4.71239)
("182" "181" 1.0 1.5708 0.0 7.51307 4.71239))>)
Select Curve:
[+] or [-] for [O]ffset, [P]erpendicularity Toggle
[M]irror Text, [S]tyle Settings, [B]ackground Mask
Before while: 185
End of while: 185
|;
                 (if (and typ val)
 

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #93 on: February 15, 2010, 06:29:11 PM »
Also, Lee.

If you remove the lines between: (foreach obj (vlr-owners *DCurve$Align$Reactor*) ... (vlr-owner-remove *DCurve$Align$Reactor* obj)))

In your condition call where reads:

(cond (  (eq "" rslt))
        (  (eq 'STR (type rslt))

Then, I don't see the bug anymore... per my few tests.... well at least to be able to marked the code lines that are not working, and you will be able to get that fixed. :)

HTH

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #94 on: February 15, 2010, 06:30:42 PM »
- I am looking at your code now.

and on this line:
Code: [Select]
(vl-prin1-to-string
                             (vl-remove-if
                               (function
                                 (lambda (x) (eq Hnd (car x)))) xDat))

That sometimes return: "nil" and that it is saved.
In there with the (entget) you are trying to make sure that the handle is valid no?, that's why you recreate the xdata.

Code: [Select]
                 (vla-GetXData obj app 'typ 'val)

(print (vlax-safearray->list val))
;|
DTCURVE
Type or Select Text <TEXT1> :
Handle selected: 182
(#<variant 8 DTCURVE> #<variant 8 (("185" "181" 1.0 1.5708 0.0 6.44746 4.71239)
("182" "181" 1.0 1.5708 0.0 7.51307 4.71239))>)
Select Curve:
[+] or [-] for [O]ffset, [P]erpendicularity Toggle
[M]irror Text, [S]tyle Settings, [B]ackground Mask
Before while: 185
End of while: 185
|;
                 (if (and typ val)
 

Yes, everytime I deal with the xData, I check that no text objects associated with the object have been deleted, and hence the handle isn't valid, and if they are, I remove them from the xData.

I don't think it would matter if the xData is set to 'nil' if the entity is the only one aligned to the object and then removed, as this would just be appended to when new entities are aligned - but I could be wrong of course.

Thanks for taking the time to help me Luis, I appreciate it  :-)

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #95 on: February 15, 2010, 06:34:33 PM »
Also, Lee.

If you remove the lines between: (foreach obj (vlr-owners *DCurve$Align$Reactor*) ... (vlr-owner-remove *DCurve$Align$Reactor* obj)))

In your condition call where reads:

(cond (  (eq "" rslt))
        (  (eq 'STR (type rslt))

Then, I don't see the bug anymore... per my few tests.... well at least to be able to marked the code lines that are not working, and you will be able to get that fixed. :)

HTH

Very true - but what I don't understand is that there is nothing in that code snippet that would change the value of the 'tObj' (Text Object) variable, and hence change which text object is moved...   :|

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #96 on: February 15, 2010, 08:16:09 PM »
Lee,

It is getting difficult for me to become familiar again with object reactors, but for what I am seeing it is the way you setup the reactor, for example why there is a foreach to go over the xdata inside of the callback (modified event) instead of placing a dependent object (the selected text of new one) in the callback function defintion, that way when it is verified inside of the callback/event it will be easier to extracted there and also any extra data attached outside.

Clear as mud?

Not that I want you change anything, but did you see what I did on reactorswiz?... in there (and I know you are trying to do that too) you will see that there is a single object reactor that can handle as many objects as you want, don't know.

And yes, it is weird stuff what it is happening in the code lines, will give it another try need more coffee... :)

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #97 on: February 15, 2010, 08:21:08 PM »
It is getting difficult for me to become familiar again with object reactors, but for what I am seeing it is the way you setup the reactor, for example why there is a foreach to go over the xdata inside of the callback (modified event) instead of placing a dependent object (the selected text of new one) in the callback function defintion, that way when it is verified inside of the callback/event it will be easier to extracted there and also any extra data attached outside.

Do you mean add the new text object as another owner in the ObjectReactor? Sorry Luis if I have misunderstood.  :oops:

Not that I want you change anything, but did you see what I did on reactorswiz?... in there (and I know you are trying to do that too) you will see that there is a single object reactor that can handle as many objects as you want, don't know.

And yes, it is weird stuff what it is happening in the code lines, will give it another try need more coffee... :)

I shall take a look at your reactorswiz  :-)

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #98 on: February 15, 2010, 08:27:38 PM »
It is getting difficult for me to become familiar again with object reactors, but for what I am seeing it is the way you setup the reactor, for example why there is a foreach to go over the xdata inside of the callback (modified event) instead of placing a dependent object (the selected text of new one) in the callback function defintion, that way when it is verified inside of the callback/event it will be easier to extracted there and also any extra data attached outside.

Do you mean add the new text object as another owner in the ObjectReactor? Sorry Luis if I have misunderstood.  :oops:

Not that I want you change anything, but did you see what I did on reactorswiz?... in there (and I know you are trying to do that too) you will see that there is a single object reactor that can handle as many objects as you want, don't know.

And yes, it is weird stuff what it is happening in the code lines, will give it another try need more coffee... :)

I shall take a look at your reactorswiz  :-)

I think I posted some samples using what it is inside of that, like:
Code: [Select]
;;; function to attach the reactor to the objects
(defun keynote-attach
       (vla_bubble
vla_line
vla_arrowhead)

  ;; make sure the objects are valid
  (if (rwiz-valid-objects
(list vla_bubble vla_line vla_arrowhead))
    (progn

      ;; hacer un solo reactor para cada objeto que forma el comando inteligente

      ;; reactor vla_bubble
      ;; make sure if the reactor is there
      (if (rwiz-added-p rwiz_reactor_bubble_line_arrowhead)

;; add owner and new data to the reactor
(rwiz-owner-data-add
  ;; reactor
  rwiz_reactor_bubble_line_arrowhead
  ;; notifier
  vla_bubble
  ;; dependents
  (list vla_line vla_arrowhead))

;; make the reactor the first time and once
(setq rwiz_reactor_bubble_line_arrowhead
       ;; notify the reactor to the active document
       (vlr-set-notification
;; type of reactor: object
(vlr-object-reactor
   ;; notifier
   (list vla_bubble)
   ;; dependents
   ;; note: we need to saved the notifier object at the beginning
   ;; of the list, this will be needed in order to
   ;; retrieve the dependent objects inside of the callback
   (list (list vla_bubble vla_line vla_arrowhead))
   ;; notes:
   ;; a. in this the bubble will be used as base for the
   ;; copied event
   ;; b. since the block has attributes we are using
   ;; the subobjmodified event
   ;; c. events used modified, subobjmodified, erased and copied
   '
    ((:vlr-modified
      .
      keynote-bubble-modified)
     (:vlr-subobjmodified
      .
      keynote-bubble-subobjmodified)
     (:vlr-erased . keynote-erased)
     (:vlr-copied . keynote-bubble-copied)))
'active-document-only)))

      ;; reactor vla_line
      ;; make sure if the reactor is there
      (if (rwiz-added-p rwiz_reactor_line_bubble_arrowhead)

;; add owner and new data to the reactor
(rwiz-owner-data-add
  ;; reactor
  rwiz_reactor_line_bubble_arrowhead
  ;; notifier
  vla_line
  ;; dependents
  (list vla_bubble vla_arrowhead))

;; make the reactor the first time and once
(setq rwiz_reactor_line_bubble_arrowhead
       ;; notify the reactor to the active document
       (vlr-set-notification
;; type of reactor: object
(vlr-object-reactor
   ;; notifier
   (list vla_line)
   ;; dependents
   ;; note: we need to saved the notifier object at the beginning
   ;; of the list, this will be needed in order to
   ;; retrieve the dependent objects inside of the callback
   (list (list vla_line vla_bubble vla_arrowhead))
   ;; events: modified and erased
   '
    ((:vlr-modified
      .
      keynote-line-modified)
     (:vlr-erased . keynote-erased)))
'active-document-only)))

      ;; reactor vla_arrowhead
      ;; make sure if the reactor is there
      (if (rwiz-added-p rwiz_reactor_arrowhead_bubble_line)

;; add owner and new data to the reactor
(rwiz-owner-data-add
  ;; reactor
  rwiz_reactor_arrowhead_bubble_line
  ;; notifier
  vla_arrowhead
  ;; dependents
  (list vla_bubble vla_line))

;; make the reactor the first time and once
(setq rwiz_reactor_arrowhead_bubble_line
       ;; notify the reactor to the active document
       (vlr-set-notification
;; type of reactor: object
(vlr-object-reactor
   ;; notifier
   (list vla_arrowhead)
   ;; dependents
   ;; note: we need to saved the notifier object at the beginning
   ;; of the list, this will be needed in order to
   ;; retrieve the dependent objects inside of the callback
   (list (list vla_arrowhead vla_bubble vla_line))
   ;; events: modified and erased
   '
    ((:vlr-modified
      .
      keynote-arrowhead-modified)
     (:vlr-erased . keynote-erased)))
'active-document-only)))

      ;; make the new reactor
      (rwiz-attach
;; custom command name
"keynote"
;; dictionary name, key and objects list
;; note: the objects list is saved in order we want it to be read
(list "SYM-REACTORS"
      "CIRCLE-BUBBLE-3"
      (list vla_bubble vla_line vla_arrowhead))))))

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #99 on: February 15, 2010, 08:38:23 PM »
and Lee,

I will kept looking at your code, and will try to solved... what I posted was simple another alternative on the mean time, what you have it is working, it simple needs more eyes and debugging.

I'll post my findings if any or not.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #100 on: February 15, 2010, 08:40:22 PM »
Thanks Luis,

I have found reactorswiz in the 'Show Your Stuff' section of the forum - quite a bit of work there, I must say.

Your reactors seem a lot more advanced than mine - using such things as:

Code: [Select]
(vlr-set-notification ... 'active-document-only)

Which I have never even seen...

And a dictionary entry:

Code: [Select]
(rwiz-attach
;; custom command name
"keynote"
;; dictionary name, key and objects list
;; note: the objects list is saved in order we want it to be read
(list "SYM-REACTORS"
      "CIRCLE-BUBBLE-3"
      (list vla_bubble vla_line vla_arrowhead))))))

Which I am not sure what it is used for  :oops:

I do only have two reactors - an object reactor with the curve objects as owners, reacting on the 'modified' callback event; and a command reactor, so that the modified callback function does not operate when an 'undo' command is called.

I didn't want to add the text objects as owners in the object reactor, as, the callback function involves modifying these objects and would hence cause the reactor to enter a recursive loop  :-(

But you seem a bit more advanced in this area after looking at your examples, so I shall study your code..

Many thanks,

Lee
« Last Edit: February 15, 2010, 08:44:20 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #101 on: February 15, 2010, 08:42:00 PM »
and Lee,

I will kept looking at your code, and will try to solved... what I posted was simple another alternative on the mean time, what you have it is working, it simple needs more eyes and debugging.

I'll post my findings if any or not.

Thanks Luis, I really appreciate you donating your time to this  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #102 on: February 15, 2010, 11:28:30 PM »
I haven't seen the problem yet. I tried a few test this evening & must be doing something wrong.
What process exactly is creating the problem?

See you in the morning, my morning   8-)
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: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #103 on: February 16, 2010, 11:19:38 AM »
I haven't seen the problem yet. I tried a few test this evening & must be doing something wrong.
What process exactly is creating the problem?

See you in the morning, my morning   8-)

Sorry for late reply - our time zones aren't good for this sort of thing  8-)

The problem occurs if you do the following:

  • Align Object A with Curve A
  • Align Object B with Curve A
  • Re-Align Object B with Curve A

You will notice that Object A gets used in place of Object B, when re-aligning.  :-(

But there is another issue I have just found with with a (read nil), as Luis quite rightly pointed out earlier.  :oops:

Will get back to you soon,

Lee

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #104 on: February 16, 2010, 11:35:59 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
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.