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

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #75 on: December 01, 2009, 08:06:40 PM »
Code updated to Version 2.4 to fix bug found with dialog - please report if any more bugs are found  8-)

Cheers,

Lee

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #76 on: December 02, 2009, 09:56:18 AM »
Apologies, forgot to update the Version number in the Dialog title...  :oops: Code updated to reflect this.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #77 on: December 03, 2009, 02:23:37 PM »
I have updated the code in the first post to Version 2.5 so that it should highlight text upon mouse-over.   :-)

Crank

  • Water Moccasin
  • Posts: 1503
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #78 on: December 04, 2009, 07:09:09 AM »
Hi Lee,

Excellent tool! I use it all the time.

I wonder if it's possible to keep the text allways on te same side of the entity. Now it often jumps to the other side.
Vault Professional 2023     +     AEC Collection

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #79 on: December 04, 2009, 08:15:56 AM »
Hi Lee,

Excellent tool! I use it all the time.

I wonder if it's possible to keep the text allways on te same side of the entity. Now it often jumps to the other side.

Thanks Crank  :-)

To get the text on the same side upon updating would be very difficult, as it is hard to determine a "side" to an object... but I shall investigate and see what I can come up with  :wink:

KOWBOI

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #80 on: December 04, 2009, 12:37:55 PM »
I would love to use this, how can I download the code?

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #81 on: December 04, 2009, 12:39:32 PM »
I'm not sure what the permissions are on this site as to how many posts you need (if any) to download attachments, but if you can, just click on the attachment in the first post  :wink:

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #82 on: December 04, 2009, 01:17:03 PM »
Hi Lee,

Excellent tool! I use it all the time.

I wonder if it's possible to keep the text allways on te same side of the entity. Now it often jumps to the other side.

Thanks Crank  :-)

To get the text on the same side upon updating would be very difficult, as it is hard to determine a "side" to an object... but I shall investigate and see what I can come up with  :wink:
Here's an idea, determine which side of the object the crosshairs are on (by determining the angle that they are from the object) and place the text on the side of the object that the crosshairs are on (based on that angle)?

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #83 on: December 04, 2009, 07:25:02 PM »
I have updated the first post to Version 2.6 to include the option to remove all text/object associativity in the Drawing at once when using the DTRemove function.

Thanks for the suggestion Willie.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #84 on: December 06, 2009, 06:43:58 PM »
I have updated the first post to Version 2.6 to include the option to remove all text/object associativity in the Drawing at once when using the DTRemove function.

Thanks for the suggestion Willie.

You did a very good job with this Lee.. :-)
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #85 on: December 06, 2009, 06:51:09 PM »
I have updated the first post to Version 2.6 to include the option to remove all text/object associativity in the Drawing at once when using the DTRemove function.

Thanks for the suggestion Willie.

You did a very good job with this Lee.. :-)

Thanks Andrea :-)

I am actually working on one final Version that uses a completely different method to re-align text and should mean that the text stays on the side that it is aligned to. But what with the Uni work, time is tight and I can only work on it when I get a spare minute...

Thanks :)

Lee

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #86 on: December 07, 2009, 12:48:35 PM »
Ok, I have updated the code to Version 2.7.

In this version, I have restructured the way that the information is stored in the xData of an object, and hence any text that has been aligned with previous versions will need to be re-aligned (using DTRemove, then DTCurve).

I have changed the way that the text is re-aligned to the object, which should make it more predictable, and also should keep the text on the correct side of the object.

Of course, criticism/comments are welcome, and any bug reports.

Enjoy!

Lee
« Last Edit: December 07, 2009, 12:52:16 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #87 on: February 15, 2010, 02:20:59 PM »
Following a bug report from over at CADTutor, I have updated the code in the first post to Version 2.8

However I cannot seem resolve a bug in which the user aligns 'object A', then aligns 'object B' to the same curve.

Then, if the user realigns 'object A' to the same curve again, 'object B' is used  :|

Any advice on this bug is welcome.

Lee

LE3

  • Guest
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #88 on: February 15, 2010, 04:55:06 PM »
Following a bug report from over at CADTutor, I have updated the code in the first post to Version 2.8

However I cannot seem resolve a bug in which the user aligns 'object A', then aligns 'object B' to the same curve.

Then, if the user realigns 'object A' to the same curve again, 'object B' is used  :|

Any advice on this bug is welcome.

Lee

First time I look at your coding style.

Did a quick review to your code, and the problem appears to be in this segment and in there it is flipping the handles - don't have much time to look in deep:
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

                     (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))))))))

               (vlr-owner-remove *DCurve$Align$Reactor* obj)))

It might a good idea to place some temp string tags to display the first value, the second and third one, to verify your findings like:

Code: [Select]
        (  (eq 'ENAME (type rslt))

           (setq *Mac$Str* (vla-get-TextString
                             (setq tObj (vlax-ename->vla-object rslt)))
                 
                 tSze (vla-get-Height tObj)

                 Hnd  (vla-get-Handle tObj))

   (princ "\nHandle selected: ")
           (princ Hnd) (princ)
 

And here:
Code: [Select]
   (princ (setq msg (strcat "\n[+] or [-] for [O]ffset, [P]erpendicularity Toggle"
                           "\n[M]irror Text, [S]tyle Settings"
                           (if (eq "AcDbText" oNme) "" ", [B]ackground Mask"))))

  (setq handleStart (vla-get-handle tObj))
  (princ "\nBefore while: ")
  (princ handleStart) (princ)

  (while
    (progn
      (setq gr (grread t 15 0) code (car gr) data (cadr gr))

And:
Code: [Select]
            (  (= 25 code) nil)

            (t ))))

  (setq handleEnd (vla-get-handle tObj))
  (princ "\nEnd of while: ")
  (princ handleEnd) (princ)

  (vla-EndUndoMark doc)
  (redraw)
 

And if I may.-

1. I see that you want to keep all code clean and formatted, but I won't place my general functions inside of my main one and even in between important calls it is break by a place of a function, I know it is a preference style, but outside can be more useful, just use your own prefix_ to mark it.

2. Why call or set at the end your local variables to nil? if that it is done by autolisp ?

Hope that you won't mind, my 0.0002 cts. :)

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #89 on: February 15, 2010, 05:21:20 PM »
Following a bug report from over at CADTutor, I have updated the code in the first post to Version 2.8

However I cannot seem resolve a bug in which the user aligns 'object A', then aligns 'object B' to the same curve.

Then, if the user realigns 'object A' to the same curve again, 'object B' is used  :|

Any advice on this bug is welcome.

Lee

First time I look at your coding style.

Did a quick review to your code, and the problem appears to be in this segment and in there it is flipping the handles - don't have much time to look in deep:
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

                     (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))))))))

               (vlr-owner-remove *DCurve$Align$Reactor* obj)))

It might a good idea to place some temp string tags to display the first value, the second and third one, to verify your findings like:

Code: [Select]
        (  (eq 'ENAME (type rslt))

           (setq *Mac$Str* (vla-get-TextString
                             (setq tObj (vlax-ename->vla-object rslt)))
                 
                 tSze (vla-get-Height tObj)

                 Hnd  (vla-get-Handle tObj))

   (princ "\nHandle selected: ")
           (princ Hnd) (princ)
 

And here:
Code: [Select]
   (princ (setq msg (strcat "\n[+] or [-] for [O]ffset, [P]erpendicularity Toggle"
                           "\n[M]irror Text, [S]tyle Settings"
                           (if (eq "AcDbText" oNme) "" ", [B]ackground Mask"))))

  (setq handleStart (vla-get-handle tObj))
  (princ "\nBefore while: ")
  (princ handleStart) (princ)

  (while
    (progn
      (setq gr (grread t 15 0) code (car gr) data (cadr gr))

And:
Code: [Select]
            (  (= 25 code) nil)

            (t ))))

  (setq handleEnd (vla-get-handle tObj))
  (princ "\nEnd of while: ")
  (princ handleEnd) (princ)

  (vla-EndUndoMark doc)
  (redraw)
 

And if I may.-

1. I see that you want to keep all code clean and formatted, but I won't place my general functions inside of my main one and even in between important calls it is break by a place of a function, I know it is a preference style, but outside can be more useful, just use your own prefix_ to mark it.

2. Why call or set at the end your local variables to nil? if that it is done by autolisp ?

Hope that you won't mind, my 0.0002 cts. :)

Hey Luis (think its you),

Many thanks for your time in looking at my code - it is appreciated.

I agree - the 'handle switching' does seem to be occurring when I check whether the text is already aligned to an object - and I tried to resolve it before posting the new code using the debugging strings (as you have also suggested) - and I think it occurs when I write the xdata to the object after removing the existing handle from the list, but I have no idea as to why they would switch  :|

I would normally localise all my functions within my main code, I realise that this makes them slightly slower when calling them, but it means they do not clash with functions that are perhaps defined in other programs - as you say, a prefix would get around this.

As for setting my variables to nil - this was just something I tried to see if it would fix the handle switching issue - I thought perhaps that the variable holding the text object was not being released, even though the variable was localised, so I set all variables to nil manually to make sure - but it didn't make a difference  :|

Lee