MichaelAllfire 发表于 2022-7-5 17:59:46

所以我在业余时间继续修补,主要是为了更好地使用lisp编码,并提出了这段代码。
 
(defun c:aspacing ()                                                ;define function
(setq a (getpoint "\nFirst Point "))         ;first point
(setq b (getpoint "\nSecond Point " a)) ;second point
(setq x (/ (distance a b) 4200))                ;divide distance from a to b by 4200
(setq y (fix (1+ x)))                                        ;round up to next whole number
(setq z1 (/ (distance a b) y))                        ;value of S - divide distance a b by whole number
(setq z2 (/ (/ (distance a b) y) 2))        ;value of half S
(setq ang (angle a b))                                        ;set angle of distance
(setq a1 (polar a ang z2))                                ;starting point for xline
(command "xline" a1 (polar a1 (+ ang 1.570795765134617) 100)"")                ;draw xline perpendicular to ab
(command "offset" z1 a1 "m" (repeat y(b)) "" "")                 ;offset y number of times
)                                                                                        ;end function
(princ)                                                                         ;clean loading
 
我对(命令“offset”…)有问题线我使用点b作为偏移的方向,但我需要它重复y多次。我不知道在这种情况下如何重复工作。思想?

BIGAL 发表于 2022-7-5 18:01:51

简单修复(重复y(命令b))您需要提供一种提供点命令的方法。

MichaelAllfire 发表于 2022-7-5 18:06:57

嗨,比格尔!谢谢,效果很好。我已经更新了我的代码,添加了第二次运行,使网格与我上一篇文章中的网格相似。它似乎工作得很好,尽管我的代码感觉有点初级。现在看起来是这样的。
 
7
 
在我的图形上选择随机点时效果很好,但当我使用矩形的角点或直线的端点时,它就会在等待我输入连接线的通过点时卡住。构造线的基点始终是我单击的第一个点。思想?这是我可能不知道的xline命令的一个怪癖吗?
 
对我的代码还有其他评论吗?
页: 1 [2]
查看完整版本: Lisp routin的故障排除