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

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Dynamic Align Text to Curve { with Reactors }
« on: November 12, 2009, 08:16:53 AM »
I realise that I have laboured over the topic of aligning text to something - but I wanted to brush up on my knowledge of reactors and xData, so I have strived to create this program, which will align DText/MText to any Curve Object, and will re-align the text when the object is modified.

More as a learning exercise, but some of you may get some use out of it  8-)







Function Syntax:  DTCurve  /  DTRemove

Code: [Select]
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;;                                                                               ;;
;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;;
;;                                                                               ;;
;;                                                                               ;;
;;                     --=={  Dynamic Text Curve Align  }==--                    ;;
;;                                                                               ;;
;;  The Program will prompt the user to either Select existing text to align,    ;;
;;  or specify New Text. The user will then be prompted to select a curve, and   ;;
;;  the text specified/selected will be dynamically aligned to the selected      ;;
;;  curve.                                                                       ;;
;;                                                                               ;;
;;  Additionally, the user can press +/- to alter the text offset from the curve ;;
;;  and furthermore, toggle the text perpendicularity by pressing 'P' during     ;;
;;  text alignment. A Background Mask can be toggled by pressing 'B' when        ;;
;;  aligning MText. The Text can also be mirrored by pressing 'M' during text    ;;
;;  alignment. The TextStyle and Text Height may be altered by pressing 'S' when ;;
;;  aligning text.                                                               ;;
;;                                                                               ;;
;;  DTRemove:-                                                                   ;;
;;  ------------                                                                 ;;
;;  This function allows the user to remove Text/Object Associativity. Upon      ;;
;;  invoking this function, the user is prompted to select either Text or        ;;
;;  object.                                                                      ;;
;;                                                                               ;;
;;  If the user picks an object, all text associativity with that object is      ;;
;;  removed. If the user picks a text object, the associativity between the      ;;
;;  text and the object that it was aligned with, is removed.                    ;;
;;                                                                               ;;
;;  The user can also press 'A' to clear all associativity within the drawing.   ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  FUNCTION SYNTAX:  DTCurve/DTRemove                                           ;;
;;                                                                               ;;
;;  Notes:-                                                                      ;;
;;  ------------                                                                 ;;
;;  Text and MText Justification will be changed to Middle Center Justification  ;;
;;  to allow text to be correctly aligned.                                       ;;
;;                                                                               ;;
;;  Background Mask functionality can only be used when aligning MText.          ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  AUTHOR:                                                                      ;;
;;                                                                               ;;
;;  Copyright © Lee McDonnell, November 2009. All Rights Reserved.               ;;
;;                                                                               ;;
;;      { Contact: Lee Mac @ TheSwamp.org, CADTutor.net }                        ;;
;;                                                                               ;;
;;  WITH ADDITIONAL THANKS TO:                                                   ;;
;;                                                                               ;;
;;  ø  Luis Esquivel (LE)                                                        ;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;  VERSION:                                                                     ;;
;;                                                                               ;;
;;    ø 1.0   ~¤~   6th November 2009   ~¤~   º First Release                    ;;
;;...............................................................................;;
;;    ø 1.1   ~¤~  13th November 2009   ~¤~   º Fixed bug that allowed text to   ;;
;;                                              aligned to multiple objects.     ;;
;;...............................................................................;;
;;    ø 1.2   ~¤~  15th November 2009   ~¤~   º Added DTRemove to remove align   ;;
;;                                              associativity.                   ;;
;;...............................................................................;;
;;    ø 1.3   ~¤~  15th November 2009   ~¤~   º Added Ability to Align MText.    ;;
;;...............................................................................;;
;;    ø 1.4   ~¤~  16th November 2009   ~¤~   º Added Ability to use a           ;;
;;                                              Background Mask, when aligning   ;;
;;                                              MText.                           ;;
;;...............................................................................;;
;;    ø 1.5   ~¤~  16th November 2009   ~¤~   º General Bug Fixes.               ;;
;;...............................................................................;;
;;    ø 1.6   ~¤~  17th November 2009   ~¤~   º Updated code to work in all UCS. ;;
;;...............................................................................;;
;;    ø 1.7   ~¤~  17th November 2009   ~¤~   º Added Logo to DTRemove function. ;;
;;...............................................................................;;
;;    ø 1.8   ~¤~  17th November 2009   ~¤~   º Fixed Bug to allow correct text  ;;
;;                                              offset/perpendicularity setting  ;;
;;                                              when updating text by Reactor.   ;;
;;                                            º General Bug Fixes.               ;;
;;...............................................................................;;
;;    ø 1.9   ~¤~  17th November 2009   ~¤~   º Fixed Text Rotation bug, for     ;;
;;                                              Vertical lines.                  ;;
;;...............................................................................;;
;;    ø 2.0   ~¤~  17th November 2009   ~¤~   º General Bug Fixes.               ;;
;;                                            º Added ability for user to        ;;
;;                                              manually input offset distance.  ;;
;;...............................................................................;;
;;    ø 2.1   ~¤~  19th November 2009   ~¤~   º DTRemove updated to remove all   ;;
;;                                              XData from object.               ;;
;;...............................................................................;;
;;    ø 2.2   ~¤~  20th November 2009   ~¤~   º Added Mirror Text Option.        ;;
;;...............................................................................;;
;;    ø 2.3   ~¤~  25th November 2009   ~¤~   º Added TextStyle/Height Dialog.   ;;
;;...............................................................................;;
;;    ø 2.4   ~¤~   2nd December 2009   ~¤~   º Fixed Dialog Bug.                ;;
;;...............................................................................;;
;;    ø 2.5   ~¤~   3rd December 2009   ~¤~   º Added Selection highlighting.    ;;
;;...............................................................................;;
;;    ø 2.6   ~¤~   4th December 2009   ~¤~   º Upgraded DTRemove function to    ;;
;;                                              include option to Remove All     ;;
;;                                              associativity from objects.      ;;
;;...............................................................................;;
;;    ø 2.7   ~¤~   7th December 2009   ~¤~   º Re-Structured xData Storage to   ;;
;;                                              allow text to be aligned to same ;;
;;                                              part of object upon re-alignment ;;
;;...............................................................................;;
;;    ø 2.8   ~¤~  15th February 2010   ~¤~   º Fixed realignment bug when line  ;;
;;                                              length is less than text.        ;;
;;                                            º General Bug Fixes.               ;;
;;...............................................................................;;
;;    ø 2.9   ~¤~  16th February 2010   ~¤~   º Updated Code Layout.             ;;
;;                                            º Added call to turn off reactor   ;;
;;                                              whilst main function is running. ;;
;;...............................................................................;;
;;                                                                               ;;
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=;;
;;                                                                               ;;
;;;¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,;;;
;;                                                                               ;;
;;;ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,¤º°`°º¤;;;

Enjoy,

Lee

[ Code Updated to Version 2.9 ]

Please Note:-
All text that has been aligned using previous Versions (pre V2.7 ) of this program will need to be re-aligned, use DTRemove, then DTCurve to re-align the text. This is due to a re-structuring of the xData stored in the object.


Code available here.
« Last Edit: November 13, 2010, 10:03:09 AM by Lee Mac »

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #1 on: November 12, 2009, 08:46:55 AM »
Moouuuaahh !!

we have same thing here..
the difference is the reactors...that we don't have.. ;-)

thanks for sharing Lee..  nice code !

Keep smile...

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #2 on: November 12, 2009, 08:50:02 AM »
Thanks Andrea.... I thought you may have had a similar program... that always seems to happen with us  :-P

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #3 on: November 12, 2009, 09:14:51 AM »
Thanks Andrea.... I thought you may have had a similar program... that always seems to happen with us  :-P

I thing that we have same vision of the future ...that's cool..  but weird.. ;-)

one little bug for your application....it is not working on diffrent UCS.
maybe need to use some "trans" conversion...

;-)
Keep smile...

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #4 on: November 12, 2009, 09:58:50 AM »
Pretty cool Lee  8-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

m4rdy

  • Newt
  • Posts: 62
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #5 on: November 12, 2009, 10:30:56 AM »
Lee,
You still always amaze me .... :love:
When i use your dtcurve with the same text but align to new different object, the text is still affected to previous object. Is that a bug?
Autocad 2007, Windows XP

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #6 on: November 12, 2009, 02:03:55 PM »
Lee, amazing code, now if I can just figure out how to add a background mask to the text, it would be perfect.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #7 on: November 13, 2009, 07:16:33 AM »
Thanks Guys  8-)

> Andrea - I hadn't really thought about the UCS yet - that comes next  ;-)

> M4rdy,

I had thought about this, and wasn't really sure how to proceed, currently the user can align the same text to two objects and the text will be aligned to the object that is updated last.

I could however implement some code that will remove the associativity from any object, when the user selects text that is already aligned.

I shall investigate with the next version :)

> cmwade77

I may include an extra option for a background mask, but I have never worked with them, so I shall have to experiment a bit. :P


Thanks for the comments guys, glad you all like the program,

Lee

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #8 on: November 13, 2009, 11:52:55 AM »
O.k., I found the problem, the routine is inserting dtext, in order for the background mask to work it needs to be mtext, any way to get this change made? (I can set the background mask once it is).

Unfortunately wipeouts don't plot correctly on our plotters, so they are not an option.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #9 on: November 14, 2009, 02:13:41 PM »
Ok, I have updated the code in the first post to Version 1.1

In this version, I have fixed the bug that allowed a single text object to be aligned to multiple objects.

I have many many ideas for this program, but little time to work on them, so I shall update it when I can  :wink:  Keep your eyes peeled  8-)

Enjoy!

Lee

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #10 on: November 14, 2009, 03:38:51 PM »
wow !! neat Lee !!

thanks.   :-)
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #11 on: November 15, 2009, 06:33:56 AM »
I have updated the code in the first post to Version 1.2  -  this version includes DTRemove a function to remove the text/object associativity.  8-)


Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #12 on: November 15, 2009, 02:45:52 PM »
Ok, I had a bit of time to work on it tonight, so I have updated the first post to Version 1.3, apologies for two updates in the same day.  :oops:

In this version, the user can align DText and MText.

I have also found a few bugs that I am working to resolve, but I wanted to release this asap, so that MText could be aligned  :wink:

Lee

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #13 on: November 16, 2009, 01:46:20 PM »
As requested, I have added the ability to use a Background Mask with MText, and have updated the code in the first post to Version 1.4

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Dynamic Align Text to Curve { with Reactors }
« Reply #14 on: November 16, 2009, 02:55:06 PM »
Wow, your code is a lot shorter than what I had for adding background masking; however, I don't know enough about VLA stuff, so my question is: How would I go about enabling background masking by default?