CAD设计论坛

 找回密码
 立即注册
论坛新手常用操作帮助系统等待验证的用户请看获取社区币方法的说明新注册会员必读(必修)
查看: 2675|回复: 3

[求助] 错误:参数类型错误 为什么?

[复制链接]
发表于 2008-5-28 22:26 | 显示全部楼层 |阅读模式
当我运行程序后,输入插入点,提示:错误:参数类型错误:numberp: nil   为什么?) Y  [' O1 W8 D2 ?  [4 ^, X6 M
我用autolisp编制绘向心球轴承的二维图形,程序如下:# S$ r" G. v2 O1 F5 w
(defun c:zch1 (/ p0 p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 pc1 pc2 a fx1 fx2 t1 )
2 _* `, }8 O" P6 k2 z- T  ^(setq d (getreal"\n 输入轴承外径"))7 R, ~( D% K3 x
(setq d1 (getreal"\n 输入轴承内径"))/ H- t5 A& U  }
(setq b (getreal"\n 输入轴承宽度"))& C. L; ?& d$ X: }
(if (> d 40)- u6 |" Y6 V/ E* O; i
(setq t1 1.5)               ;t1为绘制刨面线的线间距比例因子
. f4 E7 O9 ~, y7 K9 z) Z8 p8 l' P4 K (setq t2 0.7)# w* ?: r( f8 L# H  j. N2 P2 [
)# x+ l% [) F+ f" d" j* F
(setq a (/ (- d d1) 2.0) )     ;计算三个中间参数值
& H0 a2 y+ M, X+ w5 }: ](setq fx1 (/ pi 2))  v3 c  u7 P5 n) v
(setq fx2 (/ (* 3 pi) 2))
4 J: O+ H" J/ W$ K, d)# J3 T# B0 r& t. s/ n$ g$ m
(setq p0 (getpoint"\n 输入图形插入点:"))
' _5 g+ ]1 P# c(setq p1 (polar p0 fx1 (/ d 2.0)))
, c0 ]" T; i4 ^* k( D: Z(setq p2 (polar p1 0 b))
$ X! `/ m7 w0 b% K2 j& ~! T  F* W(setq pc1 (list (+ (car p0) (/ b 2.0)) (+ (cadr p0) (/ (- d a) 2.0))))) q: q( `. m+ \1 T7 D2 k) d$ _
(setq pc2 (polar pc1 fx2 (- d a)))       . b- b* O# B" b/ }4 I& ]- L& d4 n( |
(setq p9 (polar pc1 (/ (* pi 11) 6) (/ a 4)))* Y* |% I' T5 r' ?
(setq p8 (polar pc1 (/ (* pi 7) 6) (/ a 4)))
0 e. G$ b. d6 D1 p  {5 G5 h(setq p4 (polar pc1 (/ pi 6) (/ a 4)))  C0 F$ S% G7 u& {1 f) t
(setq p5 (polar pc1 (/ (* pi 5) 6) (/ a 4)))
6 A$ m  v2 h/ t( q  `$ c(setq p3 (list (car p2) (cadr p4)))/ z- D( D# E' j
(setq p6 (list (car p1) (cadr p5)))
; r/ b3 s" u! ]3 F5 j% F4 S" T# J(setq p7 (list (car p1) (cadr p8)))
9 R, k* D( f( K+ s8 O! D; Q(setq p10 (list (car p2) (cadr p9)))
; A/ V/ Y& D. E) A% [" M1 i, S) D(setq p11 (polar p2 fx2 a))1 ]. Z2 i! ~$ A4 [+ @
(setq p12 (polar p1 fx2 a))
6 t3 G; ^# r% E9 y% @. w/ B(setq p13 (polar p0 fx2 (/ d1 2.0)))
! F& a, x  D1 P5 |(setq p14 (polar p13 0 b))% `+ g: U. C- l9 v3 e
(setq p15 (polar p2 fx2 (/ d 2.0)))
4 @, M  U* l- M; K$ p$ y2 x(setq p16 (polar p15 0 b)). O; S  }3 O' W( p

7 J' m; W' U+ q4 D" z% y- d(nlayer)                                          ;调用层设置函数. y4 R5 H. L6 X8 b* X
(command "zoom" "w" (polar p1 fx1 10) (polar p16 fx2 10))- X5 E( T/ q  s, ^( P& D7 ^. ~5 l- {
(command "layer" "s" 1 "")                        ;绘制轴承的上半部分) D2 `# M; K5 ]  t2 F: y% B* n
(command "pline" p1 p2 p3 p4 "")' ]% `8 Y* X4 H1 C# ?/ j
(command "arc" p4 "ce" pc1 "a" 120), T. D5 V4 p9 Q2 O$ z. ~! F- v
(command "pline" p5 p6 p1 "")
4 T% E% \; [6 }7 l, @+ R; _(command "pline" p6 p7 p8 "")
8 D) k' K3 z' ^(command "arc" p8 "ce" pc1 "a" 120)( W! V' I6 c. y3 @: V+ x5 h6 R
(command "pline" p9 p10 p11 p12 p7 "")( k: G+ i/ V, F3 n2 A/ X( B2 N
(command "pline" p3 p10 "")4 x8 @! G( F2 ?5 Q* i9 {
(command "arc" p9 "ce" pc1 p4)6 d1 P  n, B  ~. c, o* G. Y! j6 t
(command "arc" p5 "ce" pc1 p8)
+ ?6 F9 q6 a' m1 b. j1 M, ](command "mirror" "w" p1 p11 "" p0 (polar p0 0 b) "")  ;镜像绘制轴承的下半部分7 Q  n. i; T( F3 X% Q
(command "pline" p12 p13 "")
9 e4 o) p7 {- F) V  q$ Q3 L( U(command "pline" p11 p14 "")
5 `8 T8 q! L/ Z3 k9 \  }, D) I(command "layer" "s" 0 "")
  N/ \9 C' l, a! ?+ U(command "hatch" "ansi31" t1 "0" "w" p1 p3 "")         ;绘制剖面线
1 d* r( k; ~5 [' z/ `; b  z(command "hatch" "ansi31" t1 "90" "w" p7 p11 "")& Y4 s+ j' ^" _
(command "hatch" "ansi31" t1 "90" "w" p13 (polar p16 fx1 (/ a 2)) "")
" e) X! X$ z$ Z5 `2 q, J) T8 l(command "hatch" "ansi31" t1 "0" "w" p15 (polar p16 fx1 (/ a 2)) "")
7 O# D; e1 Z0 j' t; G: r(command "layer" "s" 3 "")  P# m$ W7 y$ ~2 U  F2 t
(command "pline" (polar p0 pi 2) (polar p0 0 (+ b 2)) "") ;绘制轴承中心线0 k7 x( V* C( b
(command "pline" (polar pc1 fx1 (* 1.2 (/ a 4.0)))        ;绘制滚珠中心线6 t- R# ^$ B) p
         (polar pc1 fx2 (* 1.2 (/ a 4.0))) "")) t* ~, i# m2 P% k
(command "pline" (polar pc1 pi (* 1.2 (/ a 4.0)))
: e, p  t& a2 D. p         (polar pc1 0 (* 1.2 (/ a 4.0))) "") 3 |+ U, m# l' S7 r8 V1 z
(command "pline" (polar pc2 fx1 (* 1.2 (/ a 4.0)))
* J2 U  q" f. `: |$ ]: C7 B         (polar pc2 fx2 (* 1.2 (/ a 4.0))) "")
7 B0 a, k5 U) o(command "pline" (polar pc1 pi (* 1.2 (/ a 4.0)))
" F: N$ G$ _& A4 m/ y9 G5 F# v         (polar pc2 0 (* 1.2 (/ a 4.0))) "")
5 N0 ~, ^5 k5 [6 `9 N8 W# s(command "zoom" "a")
+ ]" L9 L: n! _0 E6 C9 g6 v(command "regen"); ?1 {3 q- n9 ^3 j
)+ h! \" Q5 N& w( v) {/ N
(defun nlayer ()
7 o* u6 @* E2 G: r(command "layer" "n" 1 "c" 1 1 "1" "continuous" 1 "")
, |9 L: P/ o/ {(command "layer" "n" 2 "c" 2 2 "1" "dashed" 2 "")) e0 W. b' c9 r; V* }. [& p9 M
(command "layer" "n" 3 "c" 3 3 "1" "center2" 3 "")$ t# {" V8 x" R& i
(command "layer" "n" 4 "c" 4 4 "1" "divide2" 4 "")
. Y, q2 k( M% v, A3 R% B- B)% s3 k! ^9 e0 l4 Z. Y7 K* m1 l
, D6 l8 Q$ p: x0 F$ i) @" t
[ 本帖最后由 jianjian88 于 2008-5-31 18:19 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
发表于 2008-5-28 22:45 | 显示全部楼层
好复杂,没看懂啊!不好意思
发表于 2008-5-29 14:16 | 显示全部楼层
(setq p5 (polar pc1 (/ (* pi 5) 6 (/ a 4)))    这个错误了,少了个“)”" ~7 e  B$ g& D. \; C' t! F
正确的应该是  e+ ^4 [5 p/ M/ a# E7 O3 u2 L1 z
(setq p5 (polar pc1 (/ (* pi 5) 6) (/ a 4)))
 楼主| 发表于 2008-5-31 17:59 | 显示全部楼层

回复 #3 mitenickevin 的帖子

谢谢你能看完我的程序,指出我的错误。可是依然列表有缺陷。为什么呢?
. B3 e# v8 {1 Z, E1 }% h请问Autolisp有没有查找错误的方法?谢!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于|免责|隐私|版权|广告|联系|手机版|CAD设计论坛

GMT+8, 2025-12-5 19:08

CAD设计论坛,为工程师增加动力。

© 2005-2025 askcad.com. All rights reserved.

快速回复 返回顶部 返回列表