butelys Posted May 13, 2014 Posted May 13, 2014 The function worked few days ago I dont get it, help me pls when i press enter all the way I get the error: bad argument type: 2D/3D point: nil (defun dtr (alfa) (* pi (/ alfa 180.0)) ) ;------------------------------------------- (defun duom () (setq p0 (getpoint "\n Pazymek pradzios taska:")) (if (null p0) (setq p0 (list 150.0 150.0))) (setq H (getdist "\n Ivesk auksti H :")) (if (null H) (setq H 30)) (setq a (getdist "\n Ivesk ilgi a :")) (if (null a) (setq a 18.6)) (setq b (getdist "\n Ivesk aukti b :")) (if (null b) (setq b 7.2)) (setq R (getdist "\n Ivesk ilgi R :")) (if (null R) (setq R 18.6)) (setq L (getdist "\n Ivesk ilgi L :")) (if (null L) (setq L 25)) (setq w (getdist "\n Ivesk linijos stori W :")) (if (null w) (setq w 0.5)) ) ;----------------------------------- (defun koord () (setq p1 (polar p0 (dtr 90) H)) (setq p2 (polar p1 0 (- L a))) (setq P7 (polar p2 (dtr 0) a)) (setq P3 (polar p7 (dtr 270) b)) ;(setq p4 (polar P3 (dtr 270) R )) ;(setq p5 (polar P4 (dtr 180) R )) (setq P6 (polar p5 (dtr 270) (- H (+ R b)))) ) ;----------------------------------- (defun braiz () (command "PLINE" p0 "w" w "" p1 p2 p3 "ARC" "A" "-90" p5 "L" p6 p0 "") (setq pl (entlast)) (command "hatch" "ansi31" 1 0 pl "") ) ------------------------------------------------------- (defun C:zzz() (duom) (koord) (braiz) (princ) ) Quote
hmsilva Posted May 13, 2014 Posted May 13, 2014 The p5 don't have any value, is commented... And then you are using p5 when setting p6 Henrique Quote
butelys Posted May 13, 2014 Author Posted May 13, 2014 I know the system don't need them it was the mistake before, but the system worked well without them, don't get it. Please don't look at p4 and p5 it's not the problem Quote
hmsilva Posted May 13, 2014 Posted May 13, 2014 I know the system don't need them it was the mistake before, but the system worked well without them, don't get it. Please don't look at p4 and p5 it's not the problem (setq P6 (polar [color="red"][b]p5[/b][/color] (dtr 270) (- H (+ R b)))) HTH Henrique Quote
butelys Posted May 13, 2014 Author Posted May 13, 2014 Changed the thing, but it shows the same error. Quote
hmsilva Posted May 13, 2014 Posted May 13, 2014 you'll need to set p4 and p5 (setq p4 (polar P3 (dtr 270) R )) (setq [color="red"][b]p5[/b][/color] (polar [color="red"][b]P4[/b][/color] (dtr 180) R )) (setq P6 (polar [color="red"][b]p5[/b][/color] (dtr 270) (- H (+ R b)))) ;; and (command "PLINE" p0 "w" w "" p1 p2 p3 "ARC" "A" "-90" [color="red"][b]p5[/b][/color] "L" p6 p0 "") Just uncomment p4 and p5, load the code and test it... Henrique Quote
butelys Posted May 13, 2014 Author Posted May 13, 2014 Its the same error, I did what you say (setq p1 (polar p0 (dtr 90) H)) (setq p2 (polar p1 0 (- L a))) (setq P7 (polar p2 (dtr 0) a)) (setq P3 (polar p7 (dtr 270) b)) (setq p4 (polar P3 (dtr 270) R )) (setq p5 (polar P4 (dtr 180) R )) (setq P6 (polar p5 (dtr 270) (- H (+ R b)))) Quote
MSasu Posted May 14, 2014 Posted May 14, 2014 I think Henrique is right, you must have a value for p5 variable since is used further in code. By un-commenting said lines, the routine works here, too. If you tested again just the code from post #7, please pay attention that you just shifted the issue - here you were missing the value for p0 variable. Please edit your previous posts and add the required code tags. Quote
Mesut Posted December 20, 2021 Posted December 20, 2021 Hi friends, i didnt want to open new topic, i have same problem. How we can get distance between 2 points which has different elevation. Distance between this 2 point (1363.4 1467.25 5.3) (1386.27 1474.85 5.5) (defun c:ucg() (setq noks (ssget (list (cons 0 "point")))) ;just select the points (setq len (sslength noks)) (setq counter 0) (while (< counter len) (setq txt (ssname noks counter)) (setq txtdata (entget txt)) (setq kord1 (cdr (assoc 10 txtdata))) (setq txt1 (ssname noks (+ counter 1))) (setq txtdata1 (entget txt1)) (setq kord2 (cdr (assoc 10 txtdata1))) (setq mes (distance kord1 kord2)) ; this line give error message (setq counter (+ counter 1)) );end while );end of program Quote
mhupp Posted December 20, 2021 Posted December 20, 2021 (edited) @Mesut Your lisp computes all distances but because mes keeps getting reset it will only have the distance of the last two points. You can get dist from 3d points. your two points dist = 30.67 The error you getting is due to a bad while lets say you have 3 points in your noks selection set ssname noks 0 ssname noks 1 ssname noks 2 first pass counter = 0 dist noks 0 & noks 1 counter = 1 dist noks 1 & noks 2 counter = 2 dist noks 2 & noks 3 error because noks 3 doesn't exist update while to (while (< counter (- len 1)) or (repeat (- len 1) -edit- (defun c:ucg (/ noks kord1 kord2 mes c len) (setq noks (ssget '((0 . "POINT")))) (if (<= (setq len (sslength noks)) 1) ;need a minimum of two points (prompt "\nNot Enought Points Selected") (progn (setq c 0) (repeat (- len 1) (setq txtdata (entget (ssname noks c)) txtdata1 (entget (ssname noks (setq c (+ c 1)))) kord1 (cdr (assoc 10 txtdata)) kord2 (cdr (assoc 10 txtdata1)) mes (distance kord1 kord2) ) (prompt (strcat "\nDistance : " (rtos mes 2))) ;don't know what your doing with mes but this will display it. ) ) ) (princ) ) Edited December 20, 2021 by mhupp 2 Quote
Mesut Posted December 21, 2021 Posted December 21, 2021 15 hours ago, mhupp said: @Mesut Your lisp computes all distances but because mes keeps getting reset it will only have the distance of the last two points. You can get dist from 3d points. your two points dist = 30.67 The error you getting is due to a bad while lets say you have 3 points in your noks selection set ssname noks 0 ssname noks 1 ssname noks 2 first pass counter = 0 dist noks 0 & noks 1 counter = 1 dist noks 1 & noks 2 counter = 2 dist noks 2 & noks 3 error because noks 3 doesn't exist update while to (while (< counter (- len 1)) or (repeat (- len 1) -edit- Thank you, I got it. (defun c:ucg (/ noks kord1 kord2 mes c len) (setq noks (ssget '((0 . "POINT")))) (if (<= (setq len (sslength noks)) 1) ;need a minimum of two points (prompt "\nNot Enought Points Selected") (progn (setq c 0) (repeat (- len 1) (setq txtdata (entget (ssname noks c)) txtdata1 (entget (ssname noks (setq c (+ c 1)))) kord1 (cdr (assoc 10 txtdata)) kord2 (cdr (assoc 10 txtdata1)) mes (distance kord1 kord2) ) (prompt (strcat "\nDistance : " (rtos mes 2))) ;don't know what your doing with mes but this will display it. ) ) ) (princ) ) 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.