tranchan Posted February 8, 2015 Share Posted February 8, 2015 (edited) I got same problem with coordination. My code has error like this: "error: bad argument type: 2D/3D point:nil " (defun dtr (a) (* pi (/ a 180.00)) ) (defun rtd (a) (/ (* a 180.00) pi) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:Dome () (setq osm (getvar "osmode")) (setq dK (getdist "\nDiameter of dome: ")) (setq hv (getreal "\nHeight of dome: ")) (setq n (getint "\nNumber of grid: ")) (setq p1 (getpoint "\nBase point: ")) (setq goc (/ 360 n)) (setq alpha (dtr goc )) ;(setq beta (dtr (- 180 goc)) ) (setq beta (dtr (/ (- 180 goc) 2) )) (setvar "cmdecho" 1) (setvar "osmode" 0) (setq p2 ( polar p1 (* 0 pi) dK) ) (setq pc (mid p1 p2)) (setq ra (distance p1 pc)) (setq canh (* 2 ra (sin (/ alpha 2) )) ) (setq p3 (polar p1 beta canh )) (setq x1 (car pc) y1 (cadr pc) z1 (caddr pc) ) (setq z2 (+ z1 hv)) (setq pdc (list x1 y1 z2)) (command "line" p1 p3 "" ) (setq s1 (entlast)) (command "-array" s1 "" "p" pc n "" "" ) (command "_.ucs" "zaxis" zo pdc) (setq zo (trans zo 0 1)) (setq phi (/ 180 8 )) (setq phi (dtr phi )) (setq canh2 (* 2 ra (sin (/ phi 2) )) ) (setq r2 (/ (+ (* dk dk) (* 4 (* hv hv)) ) (* 8 hv)) ) ; ban kinh cua vom (setq zo (- z2 r2)) (setq oc (list x1 y1 zo)) (setq deta (dtr (/ (- 180 phi) 2) )) (setq zeta (angle p1 zo)) (setq zeta1 (abs (- deta zeta))) (setq zd1 (* r2 (sin zeta1) )) (setq zeta2 (abs (- zeta1 phi))) (setq zd2 (+ zd1 (* r2 (sin (rtd zeta2)) ))) (setq zeta3 (abs (- zeta1 phi))) (setq zd3 (+ zd2 (* r2 (sin (rtd zeta3)) ))) (setq xd1 (* r2 (cos (rtd zeta1)) )) (setq xd2 (* r2 (cos (rtd zeta2)) )) (setq xd3 (* r2 (cos (rtd zeta3)) )) (setq pd2 (list xd1 y1 zd1)) (setq pd3 (list xd2 y1 zd2)) (setq pd4 (list xd3 y1 zd3)) (command "line" p1 pd2 "") (setq s2 (entlast)) (command "line" pd2 pd3 "") (setq s3 (entlast)) (command "line" pd3 pdc "") (setq s4 (entlast)) (command "-array" s2 s3 s3 "" "p" pc n "" "" ) (command "_.ucs" "p" ) (setvar "osmode" osm) (princ) ) Edited February 8, 2015 by fuccaro Adding the CODE tags Quote Link to comment Share on other sites More sharing options...
Ahankhah Posted February 8, 2015 Share Posted February 8, 2015 (defun dtr (a) (* pi (/ a 180.00))) (defun rtd (a) (/ (* a 180.00) pi)) [color=magenta](defun mid (p1 p2) (list (/ (+ (car p1) (car p2)) 2)(/ (+ (cadr p1) (cadr p2)) 2)(/ (+ (caddr p1) (caddr p2)) 2)) ) [/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:dome () (setq osm (getvar "osmode")) (setq dK (getdist "\nDiameter of dome: ")) (setq hv (getreal "\nHeight of dome: ")) (setq n (getint "\nNumber of grid: ")) (setq p1 (getpoint "\nBase point: ")) (setq goc (/ 360 n)) (setq alpha (dtr goc)) ;(setq beta (dtr (- 180 goc)) ) (setq beta (dtr (/ (- 180 goc) 2))) (setvar "cmdecho" 1) (setvar "osmode" 0) (setq p2 (polar p1 (* 0 pi) dK)) [b][color=magenta] (setq pc (mid p1 p2))[/color][/b] (setq ra (distance p1 pc)) (setq canh (* 2 ra (sin (/ alpha 2)))) (setq p3 (polar p1 beta canh)) (setq x1 (car pc) y1 (cadr pc) z1 (caddr pc) ) (setq z2 (+ z1 hv)) (setq pdc (list x1 y1 z2)) (command "line" p1 p3 "") (setq s1 (entlast)) (command "-array" s1 "" "p" pc n "" "") [b][color=magenta] ;;-----> (setq zo (trans zo 0 1));<----- (command "_.ucs" "zaxis" zo pdc);<----- ;;<----- [/color][/b] (setq phi (/ 180 ) (setq phi (dtr phi)) (setq canh2 (* 2 ra (sin (/ phi 2)))) (setq r2 (/ (+ (* dk dk) (* 4 (* hv hv))) (* 8 hv))) ; ban kinh cua vom (setq zo (- z2 r2)) (setq oc (list x1 y1 zo)) (setq deta (dtr (/ (- 180 phi) 2))) (setq zeta (angle p1 zo)) (setq zeta1 (abs (- deta zeta))) (setq zd1 (* r2 (sin zeta1))) (setq zeta2 (abs (- zeta1 phi))) (setq zd2 (+ zd1 (* r2 (sin (rtd zeta2))))) (setq zeta3 (abs (- zeta1 phi))) (setq zd3 (+ zd2 (* r2 (sin (rtd zeta3))))) (setq xd1 (* r2 (cos (rtd zeta1)))) (setq xd2 (* r2 (cos (rtd zeta2)))) (setq xd3 (* r2 (cos (rtd zeta3)))) (setq pd2 (list xd1 y1 zd1)) (setq pd3 (list xd2 y1 zd2)) (setq pd4 (list xd3 y1 zd3)) (command "line" p1 pd2 "") (setq s2 (entlast)) (command "line" pd2 pd3 "") (setq s3 (entlast)) (command "line" pd3 pdc "") (setq s4 (entlast)) (command "-array" s2 s3 s3 "" "p" pc n "" "") (command "_.ucs" "p") (setvar "osmode" osm) (princ) ) Quote Link to comment Share on other sites More sharing options...
tranchan Posted February 8, 2015 Author Share Posted February 8, 2015 Thanks. I have function for midpoint but i forgot. Thanks for yo' help. Let me test it. ...... After I run it. So it still has error about point. It just draw the boundary below don't draw the curve of dome Quote Link to comment Share on other sites More sharing options...
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.