Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help to modify lisp routine

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
ASCunningham
1687 Views, 25 Replies

Help to modify lisp routine

Could someone help me out with this. I've found this lisp routine posted online and I would like to make one change to it. Right now because are text styles are set at 0 height this routine doesn't work. What I would like is have it set the current textsyle to "ba" and then run the routine but I've not been able to figure out have to do this. Any help is greatly appreciated

;;;
 ;;; ct - inserts text on line or circle
 ;;;
 (defun C:CT (/ C_LAYER BOX TP1 TP2 PT1 BTST INS
 OBJNAME OBJLST ENT_TYP LS TEST FACTOR SPT
 ANG RAD SS
 ) ;_ end of /
 (setq OLDERR *ERROR*
 *ERROR* CTERR
 ) ;_ end of setq
 (setq C_LAYER (getvar "clayer"))
 (setvar "cmdecho" 0)
 (setq OTXT TXT)
 (if (= OTXT NIL)
 (setq OTXT "")
 ) ;_ end of if
 (setq TXT (getstring (strcat "\nEnter Text " "<" OTXT ">: ") t))
 (if (= TXT "")
 (setq TXT OTXT)
 ) ;_ end of if
 (setq BOX (textbox (list (cons 1 TXT)))
 TP1 (car BOX)
 TP2 (cadr BOX)
 ) ;_ end of setq
 (while (not
 (setq PT1 (nentsel "\nSelect point on Line, or Arc: "))
 ) ;_ end of not
 (princ "\nNothing selected, try again.")
 ) ;_ end of while
 (setq BTST (osnap (cadr PT1) "qui,ins"))
 (if (not BTST)
 (progn
 (setq INS (osnap (cadr PT1) "qui,nea")
 OBJNAME (car PT1)
 OBJLST (entget OBJNAME)
 ENT_TYP (cdr (assoc 0 OBJLST))
 LS (cdr (assoc 8 OBJLST))
 TEST (osnap INS "qui,cen")
 FACTOR (getvar "dimscale")
 T_STYLE (getvar "textstyle")
 ) ;_ end of setq
 (if (not TEST)
 (progn
 (setq SPT (cdr (assoc 10 OBJLST))
 ANG (atof (angtos (angle SPT INS) 0 4))
 ) ;_ end of setq
 (if (and (> ANG 90.0) (<= ANG 270.0))
 (setq ANG (- ANG 180.0))
 ) ;_ end of if
 (if (= ANG 180.0)
 (setq ANG 0.0)
 ) ;_ end of if
 ) ;_ end of progn
 ) ;_ end of if
 (if TEST
 (progn
 (setq ANG (atof (angtos (angle INS TEST) 0 4)))
 (if (> ANG 180.0)
 (setq ANG (- ANG 180.0))
 ) ;_ end of if
 ) ;_ end of progn
 ) ;_ end of if
 (setq RAD (+ (distance TP1 TP2) (* 0.06 FACTOR)))
 (command "circle" INS "d" RAD)
 (setq SS (entlast))
 (command "trim" SS "" INS "")
 (entdel SS)
 (if TEST
 (command "text" "style" T_STYLE "m" INS (- ANG 90.0) TXT)
 (command "text" "style" T_STYLE "m" INS ANG TXT)
 ) ;_ end of if
 (command "layer" "s" C_LAYER "")
 ) ;_ end of progn
 (princ "\n\n*** Select line or arc only. ***")
 ) ;_ end of if
 (setq *ERROR* OLDERR)
 (princ)
 ) ;_ end of defun

 (defun CTERR (S)
 (if (/= S "Function cancelled")
 (princ (strcat "\nError: " S))
 ) ;_ end of if
 (if OLDERR
 (setq *ERROR* OLDERR)
 ) ;_ end of if
 (command "layer" "s" C_LAYER "")
 (princ)
 ) ;_ end of defun 

 

25 REPLIES 25
Message 21 of 26
Kent1Cooper
in reply to: Kent1Cooper

... and since it seems a better way to go about it, for the reason that it doesn't break pieces out of the labeled objects, here's a version that uses Text Masking rather than Trimming.  Go in and Edit various things where instructed, for your preferred defaults.

Kent Cooper, AIA
Message 22 of 26
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

...  here's a version that uses Text Masking rather than Trimming.  ....


And since on another thread, about labeling things with their elevations, someone asked about using a Solid for the mask rather than a Wipeout, I worked up one for User-supplied text content that does the same [LabelTextMaskS -- the S id for Solid -- in the attached].  I also fixed a few little things in the one that uses a Wipeout [LabelTextMask.lsp, without the S, in the attached].

Kent Cooper, AIA
Message 23 of 26
stevesfr
in reply to: Kent1Cooper

Kent, here is the error I'm getting when trying to run the lisp...
; warning: local variable used as function: GETTEXT
how to fix ?????
Message 24 of 26
braudpat
in reply to: Kent1Cooper

 

Hello Kent

 

Sorry but I am a tester and I understand nothing !

 

- As I said the 2 routines LEM (WipeOut/Solid) are given an error ONLY on my 64 bits French ACAD/MAP ...

but they are OK on my 32 French ACADs !

 

- And the LTM routine give the same error on both 32/64 bits of my French ACAD/MAP ...

 

>>>

Commande: APPLOAD LTT__LabelTextTrim__Kent1Cooper.LSP correctement chargé(s)
Commande:
Type LTT to Label an object with Text and Trim it across that.
Commande:
Commande: LTT
Text content: AA
Error: type d'argument incorrect: numberp: nil

<<<

 

Have you tested these routines on a ACAD 2013/2014/2015 64 bits US/English ?

 

 

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 25 of 26
Kent1Cooper
in reply to: braudpat

I have tested them on 2015 64-bit English and at the other place where I'm back on 2004.  I get that error if the drawing doesn't have a text Style of the current name, which at first is the built-in initial default.  Their initial settings reports include the current Height, and in order to report on that, they check whether the current Style has a fixed height or is zero-height -- that's a number, and if the Style isn't present, they can't find any number to check whether it's zero, which is the source of the "numberp nil" error.  Maybe the setup on which you don't get the error has a Style of that name in its default drawing template(s).

 

If that's the problem, you can either:

1.  ensure first that you have a style called ROMANS [which is the way I built it -- that's defined in our standard drawing template]; or

2.  follow the routine's instructions [search for the word "edit"] and edit that initial-default name in the code to either:

   a.  STANDARD [to assure that it will always exist, since that can't be Purged], or

   b.  some Style that you always have; or

3.  build the making of the Style you would be most likely to use into the routines [I probably will do that and re-post them, but that will still require editing by Users for their preferences].

 

I also find that the (getkword) functions in specifying the laYer for the Text don't allow for spaces in Layer names.  I don't use Layer names with spaces, but they have been possible for many years now [they weren't always].  It uses (getkword) in order to allow single-letter options for Current and Selected-object's.  I'll have to think about whether there's a way to achieve that using (getstring) instead, which has the option of allowing spaces.

Kent Cooper, AIA
Message 26 of 26
braudpat
in reply to: Kent1Cooper

 

Hello Kent

 

Sorry for the delay, I have retested the 3 routines (LEMx2 , LTM)

and of course they are OK on my ACAD / MAP French 201X 32 and 64 bits !

 

---> You were right and I am a "stupid boy" !

Because when testing, I used sometimes a DWG with a ROMANS text style and sometimes a DWG without any ROMANS text style !!

 

Thks a lot for these 3 routines which are nice, I appreciate ...

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost