CAD设计论坛

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

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

[复制链接]
发表于 2008-5-28 22:26 | 显示全部楼层 |阅读模式
当我运行程序后,输入插入点,提示:错误:参数类型错误:numberp: nil   为什么?, |; Q1 X( @, F/ Q
我用autolisp编制绘向心球轴承的二维图形,程序如下:# v: k+ c4 K$ M3 h( U5 _
(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 )
/ w* F% H5 C0 R3 v# V(setq d (getreal"\n 输入轴承外径"))
- h5 A' V% W- a4 L3 ]5 K(setq d1 (getreal"\n 输入轴承内径"))  f( w" H- @0 a  g8 j
(setq b (getreal"\n 输入轴承宽度"))' f3 ?9 j3 S5 r* z
(if (> d 40)8 k6 U# J2 I9 R: E6 W1 G' }9 n
(setq t1 1.5)               ;t1为绘制刨面线的线间距比例因子
, A9 i# P2 S) O+ _  ~ (setq t2 0.7)' ?3 q( X$ {1 M) @* ]
)
6 w7 b( f) w, h1 y(setq a (/ (- d d1) 2.0) )     ;计算三个中间参数值" b$ e$ b  V# b1 T) T& G5 h, I
(setq fx1 (/ pi 2))
5 N5 f3 d5 x2 H0 r# N$ d; s(setq fx2 (/ (* 3 pi) 2))& U* ?, F/ F8 }" a9 U
)3 C( `" B! W5 d; l
(setq p0 (getpoint"\n 输入图形插入点:"))0 r, A) M0 K: L! _! G
(setq p1 (polar p0 fx1 (/ d 2.0)))
8 B4 C, T1 V; O3 Y& k; Q' S; H(setq p2 (polar p1 0 b))# K, a9 N/ R5 e
(setq pc1 (list (+ (car p0) (/ b 2.0)) (+ (cadr p0) (/ (- d a) 2.0))))
  d; e* N( w9 A! K$ L9 E(setq pc2 (polar pc1 fx2 (- d a)))      
  F. F6 c9 a' L$ g(setq p9 (polar pc1 (/ (* pi 11) 6) (/ a 4)))
0 z& h2 F( c1 q" j. v(setq p8 (polar pc1 (/ (* pi 7) 6) (/ a 4)))
9 Z8 ?* V# r( T(setq p4 (polar pc1 (/ pi 6) (/ a 4)))
* L) k: ]4 @% H+ f/ L(setq p5 (polar pc1 (/ (* pi 5) 6) (/ a 4)))! ~& V2 X( _3 s; O$ m0 [; s
(setq p3 (list (car p2) (cadr p4)))! i" p% o* R; k
(setq p6 (list (car p1) (cadr p5)))$ Y0 P' m& [* I3 ~
(setq p7 (list (car p1) (cadr p8)))) b/ `7 a4 f  M
(setq p10 (list (car p2) (cadr p9)))
7 @, }* K6 h+ V; K. V" s(setq p11 (polar p2 fx2 a)). O* W; f! L! b
(setq p12 (polar p1 fx2 a))
* k$ b1 Q* _, `1 W& c5 F# ]8 F(setq p13 (polar p0 fx2 (/ d1 2.0)))
& _- Y5 T+ g+ b(setq p14 (polar p13 0 b)); S! p! q* _' X
(setq p15 (polar p2 fx2 (/ d 2.0))); r( j; @& G) s. L
(setq p16 (polar p15 0 b))' L9 h4 |% ^4 @7 e: d

& \3 d0 m  F$ K(nlayer)                                          ;调用层设置函数
% k: V/ x$ `- Z! n, m# b& X$ _(command "zoom" "w" (polar p1 fx1 10) (polar p16 fx2 10))& h7 L& o0 ~  B6 z9 }! T
(command "layer" "s" 1 "")                        ;绘制轴承的上半部分' h/ d7 z9 J; T9 t7 p" O
(command "pline" p1 p2 p3 p4 "")( n' S4 |$ _9 p1 H
(command "arc" p4 "ce" pc1 "a" 120)/ v. S# u% L5 J6 F& H! `" u: K
(command "pline" p5 p6 p1 "")1 g' h: H1 D: c; F% U. g
(command "pline" p6 p7 p8 "")
, i/ j" a6 j/ m0 ](command "arc" p8 "ce" pc1 "a" 120)
' a, g9 v: d( t6 Q1 H6 \(command "pline" p9 p10 p11 p12 p7 "")
; q# R! p; _' [0 W4 R(command "pline" p3 p10 "")" a% b" Z9 m: Q& B  ?
(command "arc" p9 "ce" pc1 p4)5 _/ B8 i' a" a1 \8 P% Y
(command "arc" p5 "ce" pc1 p8)
# C" l) B5 E2 v  N& K0 D(command "mirror" "w" p1 p11 "" p0 (polar p0 0 b) "")  ;镜像绘制轴承的下半部分0 r6 K& i  _$ d6 U4 }1 [, w7 a
(command "pline" p12 p13 "")
0 B. O' i2 H/ C3 m6 k(command "pline" p11 p14 "")
" X! T* O  I6 r( l9 T(command "layer" "s" 0 "")& D# g9 L0 a9 B+ g- @/ n
(command "hatch" "ansi31" t1 "0" "w" p1 p3 "")         ;绘制剖面线1 A* ^7 c( c0 P9 {: d/ E. H4 f
(command "hatch" "ansi31" t1 "90" "w" p7 p11 ""), P- z1 D" W+ x2 _2 t" N4 a# C
(command "hatch" "ansi31" t1 "90" "w" p13 (polar p16 fx1 (/ a 2)) "")7 H8 v8 ~- r7 U# S6 q
(command "hatch" "ansi31" t1 "0" "w" p15 (polar p16 fx1 (/ a 2)) ""), i  q. q3 s  n3 u2 Z: x, a
(command "layer" "s" 3 "")! {) S+ M+ _3 j- v, @" \5 G
(command "pline" (polar p0 pi 2) (polar p0 0 (+ b 2)) "") ;绘制轴承中心线
, U9 M" M, v5 x, G(command "pline" (polar pc1 fx1 (* 1.2 (/ a 4.0)))        ;绘制滚珠中心线2 _0 o5 c' D# m9 x# d% Y4 a$ J& {
         (polar pc1 fx2 (* 1.2 (/ a 4.0))) "")) G3 q4 d2 Y" ^, ]( A
(command "pline" (polar pc1 pi (* 1.2 (/ a 4.0)))0 A6 A# O4 R9 C5 \- E
         (polar pc1 0 (* 1.2 (/ a 4.0))) "")
" A) q: K- |* H% K1 ]- Y" S8 R(command "pline" (polar pc2 fx1 (* 1.2 (/ a 4.0)))
8 T2 k- V: V, i- h0 a4 E         (polar pc2 fx2 (* 1.2 (/ a 4.0))) "")
9 Y0 O( G! Z9 D: q) C(command "pline" (polar pc1 pi (* 1.2 (/ a 4.0)))* @# p0 j9 d* Z" Z
         (polar pc2 0 (* 1.2 (/ a 4.0))) "")
1 f2 G3 F+ j! \6 @& |- @# }(command "zoom" "a")' G+ ]4 C. n  I' c
(command "regen")
8 N! V: B* j$ j% c! S0 M# w)* @7 B7 A: I  v; G- X! K- \
(defun nlayer ()
" _; ~$ V, D( }(command "layer" "n" 1 "c" 1 1 "1" "continuous" 1 "")
! c/ f& {5 K8 e! d+ Y8 M% W9 ]' t(command "layer" "n" 2 "c" 2 2 "1" "dashed" 2 "")' J( k0 r0 p! e3 D$ y6 F
(command "layer" "n" 3 "c" 3 3 "1" "center2" 3 "")
6 ?% N: z' H0 j  C1 ^& r' S; W5 ^0 ^(command "layer" "n" 4 "c" 4 4 "1" "divide2" 4 "")- t1 h1 {% m9 x% i' t
)
# I2 V+ y, @5 s6 Y& X
7 ^- C2 q* D" X' m( R1 Q[ 本帖最后由 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)))    这个错误了,少了个“)”
' `; W9 P& [! f+ @3 A4 v正确的应该是2 o  Y+ [$ X, f3 \. R% e4 p' r
(setq p5 (polar pc1 (/ (* pi 5) 6) (/ a 4)))
 楼主| 发表于 2008-5-31 17:59 | 显示全部楼层

回复 #3 mitenickevin 的帖子

谢谢你能看完我的程序,指出我的错误。可是依然列表有缺陷。为什么呢?
7 g# O+ w0 a0 O' I* B1 t请问Autolisp有没有查找错误的方法?谢!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-2-19 06:29

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

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

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