Nikon Posted November 20, 2024 Posted November 20, 2024 (edited) Lisp issues an error, how can this be fixed? ; Larry Knott author ; Draws center aligned text along an ARC. The start point of the text ; is the ENDpoint of the ARC closest the pick point. ; Select arc: ; error: invalid argument type: point: nil (defun rtd (a) (* a (/ 180 pi))) ; radians to degrees (defun getarc (/ no_arc e0 e1) (setq no_arc T) (while no_arc (if (setq e0 (entsel "\nSelect arc: ")) (if (= (cdr (assoc 0 (setq e1 (entget (car e0))))) "ARC") (setq no_arc nil) (princ (strcat (cdr (assoc 0 e1)) ", Not an arc.")) ) ; end IF (princ " No object found.") ) ; end IF ) ; end WHILE (setq c1 (cdr (assoc 10 e1)) ; center point r1 (cdr (assoc 40 e1)) ; radius a0 (cdr (assoc 50 e1)) ; start arc angle a1 (cdr (assoc 51 e1)) ; end arc angle i1 (if (> a1 a0) ; included angle (- a1 a0) (+ a1 (- (* pi 2) a0)) ) ; end IF p1 (osnap (cadr e0) "_end") ; start point pick p2 (polar c1 a1 r1) ; end point arc ) ; end SETQ ) ; end DEFUN (defun getset (/ h1 t1 n1 a2) (setq h1 ; check current text style height (if (zerop (cdr (assoc 40 (tblsearch "style" (getvar "textstyle"))))) (getdist p1 "\nHeight: ") ; text height nil ; height defined by STYLE ) ; end IF t1 (getstring T "\nText: ") ; text string n1 1 ; counter a2 (/ i1 (1- (strlen t1))) ; angle increment ) ; end SETQ (if (< (distance p1 p2) 1.0E-8) ; clockwise? (setq o1 '-) ; clockwise (setq o1 '+ ; counter-clockwise a1 a0 ) ; end SETQ ) ; end IF (setvar "cmdecho" 0) ; suppress command echo (setvar "highlight" 0) ; suppress hightlighting (setvar "blipmode" 0) ; suppress blips (repeat (strlen t1) ; for each character (command "_.text" "_c" p1) ; TEXT command (if h1 (command h1)) (command ((eval o1) (rtd a1) 90) (substr t1 n1 1)) (setq a1 ((eval o1) a1 a2) ; increment angle n1 (1+ n1) ; increment counter p1 (polar c1 a1 r1) ; increment text point ) ; end SETQ ) ; end REPEAT (setvar "cmdecho" 1) ; enable command echo (setvar "highlight" 1) ; enable hightlighting (setvar "blipmode" 1) ; enable blips ) ; end DEFUN (defun c:arc2txt() (princ "\n *** Draws text on arcs ***") ; banner (getarc) ; get the arc (getset) ; get the settings and draw text (prin1) ; quiet exit ) ; end DEFUN Thanks... Edited November 21, 2024 by Nikon p1 (osnap (cadr e0) "_end") Quote
Saxlle Posted November 20, 2024 Posted November 20, 2024 I'v tried the "arc2txt" and it works well (see attached picture). Try to load it in Visual Lisp IDE, select in card Debug -> Break On Error, then run LISP and see where the error occured. Also, there is a "Arc Aligned" function in "Express Tools" (if you have it in your version of CAD) or just type a ARCTEXT command which is better then posted LISP. Best regards. 1 Quote
Nikon Posted November 21, 2024 Author Posted November 21, 2024 18 hours ago, Saxlle said: Also, there is a "Arc Aligned" function in "Express Tools" (if you have it in your version of CAD) or just type a ARCTEXT command which is better then posted LISP. I know the ARCTEXT command, but I want to understand why this code gives an error. I select the arch and: ; error: invalid argument type: point: nil Quote
Nikon Posted November 21, 2024 Author Posted November 21, 2024 5 minutes ago, Saxlle said: Can you post a dwg? This code does not work on all drawings... ARC2TXT.dwg Quote
Saxlle Posted November 21, 2024 Posted November 21, 2024 In ARC2TXT.dwg the LISP works well, i don't get an error (see attached picture). Do you have other examples (you said "on all drawings")? But according to the error I assumed that the problem is in (p1) when defining all the points for the each text value that is set to ARC, because there is no passed point value. Quote
Nikon Posted November 21, 2024 Author Posted November 21, 2024 35 minutes ago, Saxlle said: But according to the error I assumed that the problem is in (p1) when defining all the points for the each text value that is set to ARC, because there is no passed point value. And what needs to be fixed in the code? Quote
Saxlle Posted November 21, 2024 Posted November 21, 2024 Have you tried loading LISP in the Visual Lisp IDE? Before run LISP, select in the Debug -> Break On Error, then run it. After the error occurred, from Debug -> select Last Break Source to position you in the line of code where the error occurred? Quote
Nikon Posted November 21, 2024 Author Posted November 21, 2024 (edited) 8 hours ago, Saxlle said: Have you tried loading LISP in the Visual Lisp IDE? Before run LISP, select in the Debug -> Break On Error, then run it. After the error occurred, from Debug -> select Last Break Source to position you in the line of code where the error occurred? VLIDE issues such a window: Edited November 21, 2024 by Nikon Quote
Tsuky Posted November 21, 2024 Posted November 21, 2024 I haven't tried your code, but reading it I see that (command) is used but that the osmode variable is not managed. This can create bad point feedback following the current snap. Another note: I see that international mode is used, that's good. But an oversight (on line 28): (osnap (cadr e0) "end") put an underline in front of "_end" . If using a non-US version this may return a null point. I have my own version for you if you want to try it. text_curv.lsp 1 Quote
Nikon Posted November 21, 2024 Author Posted November 21, 2024 (edited) 4 hours ago, Tsuky said: I haven't tried your code, but reading it I see that (command) is used but that the osmode variable is not managed. can create bad point feedback following the current snap. Another note: I see that international mode is used, that's good. n oversight (on line 28): (osnap (cadr e0) "end") put an underline in front of "_end" . If using a non-US version this may return a null point. I have my own version for you if you want to try it. Thank you for your attention! I will fix "_end" and add osmode... Your text_curs.lsp program is wonderful, it has a lot more features (*LINE,ARC,CIRCLE,ELLIPSE). Thank you very much! Merci beaucoup! Edited November 21, 2024 by Nikon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.