这昨天起作用了,但没有
这个Lisp程序昨天对我有效。我今天试了一下,这样我可以添加更多,但它停止了工作,并给了我这个错误。(错误:错误的参数类型:numberp:nil)我找到了零的位置,但不确定如何使其工作。零在a4。它不是将2个数字除以。
(defun c:fdf (/ a5 a4 bmwdth bmcnt bmcnt1 bmcnt2 ptx1 ptx2 dltx dltx1 *error* of undo doc ss)
(vl-load-com)
;(command "setvar" "hpcolor" "bylayer")
;(command "setvar" "hplayer" ".")
(setq layerset (getvar "clayer"))
(setq bmwdth (atoi (getstring "Width of beams: "))) ;get beam width
(setq bmcnt (atoi (getstring "Number of beams: "))) ;beam count
(setq bmcnt1 (- 1 bmcnt)) ;minus one beam for space in between beams
(setq bmcnt2 (* bmcnt1 -1))
(setq ptx1 (getpoint)) ;get first point for the delta x
(setq ptx2 (getpoint)) ;get second point for delta x
(setq dltx (- (car ptx1) (car ptx2))) ;get the detla x by minusing ptx1 and ptx2
(setq dltx1 (* dltx -1)) ;turn negitive to positve
(setq crtdst (- dltx1 bmwdth)) ;minus beam width from dist to get correct dist to divide
(setq hlfbmwdth (/ bmwdth 2)) ;divide beam width in half
(setq ptx3 (car ptx1)) ;first coordinate in point
(setq strtloc (+ ptx3 hlfbmwdth)) ;start location for beams
(setq ptx4 (cadr ptx1)) ;second coordinate in point
(setq ptx5 (list strtloc ptx4)) ;both coordinates in a list
(setvar "hporigin" ptx5) ;setting the start point for beams
(setq strtloc (+ ptx3 hlfbmwdth2)) ;start location for beams
(setq a4 (/ crtdst bmcnt2)) ;divide for beam spacing
(setq a5 (* a4 -1))))) 删除此行:
(setq a3 (
更改此行:
(setq a5 (* a4 -1)))))
收件人:
(setq a5 (* a4 -1))) 对不起,那不应该在那里。(setq a3(
我把它拿了出来。在我把它贴到这里之前,我正在尝试一些东西。没有了a4仍然为零。 好的,下面是一些解剖:
(defun c:fdf ( / a4 a5 bmcnt bmcnt1 bmcnt2 bmwdth crtdst dltx dltx1 hlfbmwdth hlfbmwdth2 layerset ptx1 ptx2 ptx3 ptx4 ptx5 strtloc )
(if
(and ; prompt the user for inputs
(not (initget 6))
(setq bmwdth (getint "Width of beams: ")) ;get beam width
(not (initget 6))
(setq bmcnt (getint "Number of beams: ")) ;beam count
(setq ptx1 (getpoint "\nFirst point for delta x <exit>: ")) ;get first point for the delta x
(setq ptx2 (getpoint ptx1 "\nSecond point for delta x <exit>: ")) ;get second point for delta x
)
(progn ; proceed with calculations
;(command "setvar" "hpcolor" "bylayer")
;(command "setvar" "hplayer" ".")
(setq layerset (getvar "clayer"))
(setq bmcnt1 (- 1 bmcnt)) ;minus one beam for space in between beams
(setq bmcnt2 (* bmcnt1 -1))
(setq dltx (- (car ptx1) (car ptx2))) ;get the detla x by minusing ptx1 and ptx2
(setq dltx1 (* dltx -1)) ;turn negative to positive
(setq crtdst (- dltx1 bmwdth)) ;minus beam width from dist to get correct dist to divide
(setq hlfbmwdth (/ bmwdth 2)) ;divide beam width in half
(setq ptx3 (car ptx1)) ;first coordinate in point
(setq strtloc (+ ptx3 hlfbmwdth)) ;start location for beams
(setq ptx4 (cadr ptx1)) ;second coordinate in point
(setq ptx5 (list strtloc ptx4)) ;both coordinates in a list
(setvar "hporigin" ptx5) ;setting the start point for beams
(setq strtloc (+ ptx3 hlfbmwdth2)) ;start location for beams
(setq a4 (/ crtdst bmcnt2)) ;divide for beam spacing
(setq a5 (* a4 -1))
); progn
); if
); defun
(vl-load-com)
hlfbmwdth2变量未分配到任何位置。 用GETDIST函数替换(atoi(getstring…)。
还有一个额外的括号。 Tharwat谢谢你的信息,但a4仍然为零。可能我正在做的数学有多错。
(/crtdst bmcnt2)
crtdst是一个十进制数
bmcnt2是整数 再次谢谢你。
我想出来了。它确实与hlfbmwdth2有关。
很高兴听到这个消息。
但您的感激之情这次必须转达给Grrr。 J_spawn_h当将int除以实数时,您可以得到一个整数答案。如果您希望准确无误,最好在代码中使用2.0(setq hlfbmwdth(/bmwdth 2.0))这将允许0.5作为答案。
不完全是这样——当整数除以实数(double)时,你只会得到一个double;只有将两个整数除时,结果才会始终是整数(可能是意外的)-请注意:
_$ (/ 1.0 2.0)
0.5
_$ (/ 1 2.0)
0.5
_$ (/ 1.0 2)
0.5
_$ (/ 1 2)
0
页:
[1]
2