TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CAB on July 08, 2011, 01:20:17 PM

Title: Text Tools by CAB
Post by: CAB on July 08, 2011, 01:20:17 PM
This is a "Not Ready for Prime-time" routine I've been working on over the years.
Just thought I would share what I have so far to get feed back.
Started the routine in 2001 when my skills were poor. I purchased a routine (arx)
to do the work so I quit my own LISP but the purchased routine quit working when I
moved to ACAD2006 and a new computer recently. So I returned to this old lisp to try & add
some functionality to it.

It has a help button but most of the functions are obvious (to me).

Code: [Select]
;;;           -=<   D i a l o g    O p t i o n s   >=-   
;;;    Text Styles - Select a new style to use
;;;    Previous Settings - Select previously used settings to update the dialog box
;;;    Text Insert Angle - Angle text is inserted at
;;;    [Pick Angle] - exist dialog to pick, enter or select object for new angle
;;;    [ ] Pick Angle when adding - User must pick angle after picking the insert point
;;;    [ ] Keep text upright - Will only change the angle from the [Pick Angle] button Object option
;;;    Style Size - Display of current Text Style Size
;;;    Text Size - User size choice : Only if style is zero can user change it
;;;    [Pick Size] - exist dialog to pick, enter or select object for new text size
;;;    Layer to use - Pick list of layers to use
;;;    [ ] Use Current layer - When checked ignores pick list for layer
;;;    [Pick Layer] - exit dialog box for user to select object for new layer
;;;    Text Type to Insert - Chose Plain Text, Mtext or Mtext when more than one row is entered
;;;    [Add text to Drawing] - exist dialog to add text
;;;    [Update Text] - exit dialog box to Change existing text to match present settings
;;;    [Combine Text] - exit dialog box to combine selected text to Mtext
;;;    [Underline Text] - exit dialog to Underline selected existing text
;;;    [Match Text Properties] - exit dialog box to select text to match properties
;;;    [Help] - See this screen


The nice thing about the TextAdd function is that you do not need the dialog if you want to create
your own short cut buttons. Here are some examples:
Code: [Select]
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
;;     T e x t A d d   C o m m a n d   L i n e   C a l l s     
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
(defun c:TextAddPickAngle ()
  (TextAdd (list (list "Layer" (GetLay2Use))'("Pick" t)))
)
(defun c:TextAddFixedAngle ()
  (TextAdd (list (list "Layer" (GetLay2Use)) '("Pick" nil)))
)
;;  allow user to pick text to match properties & the add text to DWG [No DCL]
(defun c:txtMatchAdd()
  (if (ttMatchProperty)
    (TextAdd nil)
  )
)
;|   --==<    TextAdd  optional arguments     >==--
      Options is nil or a list of optional settings, example [Case Sensitive]
      '(("Layer" "0") ("Size" 5.5))               
                "Layer"  must be a valid layer name
                "Style"  must be a valid style name
                "Size"   real or integer
                "Type" integer flag
                           0 = leave as plain text
                           1 = change to mtext is > 1 line of text
                           2 = change to mtext no matter what
                "Pick"   User to pick angle flag  t or nil or "O" = Object Pick
                "Angle" Forced Text angle in degrees and can be a string
|;
;; *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*



====================================================================
I also have a Leader Routine and intend to marry the two when both are more bug resistant.
So you may see some code I dropped in that is for future use, and there are a lot of
global variables floating around that will get localized soon.

Code: [Select]
;;;  DESCRIPTION:
;;;  This is a typical Leader creation tool to allow the user to pick leader points and adjust
;;;  the arrow head type and size as overrides. The leader routine is a lisp that is called
;;;  with arguments that control the leader type, arrowhead and points allowed. This is similar
;;;  to Qleader but with the added option to change the arrow head type & size.
;;;  Initial settings are hard coded in the LISP & saved to the current drawing unless the current
;;;  drawing has the values. If they exist they are loaded and defaults are ignored.
;;;  In a future release I will add the text engine to complete the tool.
;;;  ADD LEADER will allow user to place a leader using dialog settings.                       
;;;      During the leader add process after the first point:
;;;        + increment the arrow size by one
;;;        - deincrement the arrow size by one
;;;        TAB key for arrowhead DCL
;;;        6 key to change increment arrowhead type
;;;        4 key to change deincrement arrowhead type
;;;        F8 key to toggle Ortho override
;;;        F10 key to toggle Polar override
;;;        S key to run Dialog for Settings
;;;  SAVE will store dialog settings in current session in the current drawing.               
;;;  CANCEL will exit without saving any changes in settings.                                 
;;;  MATCH will allow user to select a leader & updates dialog settings.                       
;;;  UPDATE will allow user to select a leader & updates the leader settings.                 
;;;  [Leader Type] pick list overrides the Dim Style Leader                                   
;;;  [Arrow Head] pick list overrides the Dim Style Arrow                                     
;;;  [ ] Use Current Dim Style - when unchecked will use the Dim Style in the pick list.       
;;;  [ ] Use Dim Style Size - uses DimASZ times DimScale, Actual size is displayed.           
;;;  User Arrow Size Override - Enter actual size desired.                                     
;;;  [ ] Use Current Layer - when unchecked will use the Layer in the pick list.               
;;;  [ ] Layer Filter will filter the layer selection available to the user. 


Title: Re: Text Tools by CAB
Post by: Matt__W on July 08, 2011, 01:27:07 PM
Greater is spelled wrong.
Title: Re: Text Tools by CAB
Post by: GDF on July 08, 2011, 02:09:50 PM
Looking forward to playing with these routines...
Title: Re: Text Tools by CAB
Post by: CAB on July 08, 2011, 02:29:55 PM
Thanks Matt, for those eagle eyes. 8-)

File & picture updated.
Title: Re: Text Tools by CAB
Post by: Lee Mac on July 08, 2011, 03:00:27 PM
Some impressive looking dialogs there Alan! Nice work  :-)
Title: Re: Text Tools by CAB
Post by: CAB on July 08, 2011, 03:27:07 PM
Thanks Lee, still tweaking 8-)
Title: Re: Text Tools by CAB
Post by: Jeff H on July 08, 2011, 03:40:23 PM
Your code that you consider crap is gold to most people.
Thanks Cab.

***Edit***
I hope that came across as a compliment maybe this would be better
The code you wrote while you considered your skills poor,
I wish I could write at a my best.
Title: Re: Text Tools by CAB
Post by: kdub_nz on July 08, 2011, 05:20:16 PM

Interesting that you use the 'greater than' and 'less than' symbols  for labels ...  ie  < label >
makes it quite distinctive.

I haven't played with DCL for ages but those look very effective Alan.

Regards
Title: Re: Text Tools by CAB
Post by: stevesfr on July 09, 2011, 01:05:31 PM
CAB.. he who does great code !!
is it possible to narrow the width of the dcl just a bit?
at the moment I have my screen set to 1152 x 864 pixels; with this the dcl doesn't fit, but with a little jacking around, its useable-tho not perfect.
If I change resolution to 1280 x 768 pixels, then dcl is happy, but circles in ACAD2008 are no longer true circles in appearance.
Just wondering if others are experiencing this and did they overcome it somehow?
(available for testing and breaking !)
regards for the nice programming !
Steve
Title: Re: Text Tools by CAB
Post by: CAB on July 09, 2011, 03:05:30 PM
Thanks Kerry. 8-)

Steve, see attached, I was able to shrink the right column a bit.
Title: Re: Text Tools by CAB
Post by: stevesfr on July 09, 2011, 03:14:02 PM
CAB.... beautiful new DCL...... thx   8-)
Steve
Title: Re: Text Tools by CAB
Post by: CAB on July 09, 2011, 03:25:32 PM
I was able to shrink the left column with some staking.
See attached.
Title: Re: Text Tools by CAB
Post by: stevesfr on July 09, 2011, 03:49:05 PM
Revision #1 dcl  and Revision #2 dcl are working just fine here.
Steve
Title: Re: Text Tools by CAB
Post by: qjchen on July 10, 2011, 07:32:33 AM
Thanks for sharing your nice work~, Alan
Title: Re: Text Tools by CAB
Post by: jbuzbee on July 11, 2011, 10:58:00 AM
Nice gooey CAB.

<sigh> "Imagine how useful that would be in a palette format . . ."

 :wink:
Title: Re: Text Tools by CAB
Post by: alanjt on July 11, 2011, 11:51:23 AM
Nice gooey CAB.

<sigh> "Imagine how useful that would be in a palette format . . ."

 :wink:
Man, I totally agree with you.
Title: Re: Text Tools by CAB
Post by: CAB on July 11, 2011, 12:36:18 PM
Don't use palette so I wouldn't know. :?

Just buttons for me.
Title: Re: Text Tools by CAB
Post by: curmudgeon on July 11, 2011, 01:22:29 PM
fantastic!

I logged in because I was looking to see if anyone had written something very much like this.
now, I should be able to take it apart and measure the pieces, and reassemble.
and learn something. thank you.

if I come up with something not entirely ugly, I'll return with it, so that you guys can have a good laugh.
 :lmao: