Impala62 发表于 2022-7-6 09:19:13

我试图在你的代码中添加一行代码,看看我是否能更好地理解这门语言。
 
我想将这段代码合并到另一个lisp例程中,但我想首先尝试在代码中添加一行简单的代码。
 
添加了粗体代码。
 

(defun c:hol ( / rows cols rowd rowv rowh hole )


    (setq ins (getpoint "\nInsertion Point"))
(setq len1 (getpoint "\nLength of Line"))

(setq rows (getint "\nEnter the number of rows (---) <2>: ")
       cols (getint "\nEnter the number of columns (|||) <3>: ")
       rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
       rowv (getdist (strcat "\nVertical center / center <" (rtos 50) ">: "))
       rowh (getdist (strcat "\nHorizontal center / center <" (rtos 50) ">: "))
       hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
)

(if (= rows nil)(setq rows 2))
(if (= cols nil)(setq cols 3))
(if (= rowd nil)(setq rowd 25))
(if (= rowh nil)(setq rowh 50))
(if (= rowv nil)(setq rowv 25))
(if (= hole nil)(setq hole 17.5))

   (setq ins (getpoint "\nSelect insertion point: "))
(setq pt02 (polar ins (dtr 90.0)len1 ))

(if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
(repeat cols
   (setq lstpnt (polar ins (* pi 1.5) rowd))

(command "line" ins pt02 "")

   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   (repeat (1- rows)
   (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
   (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
   )
   (setq ins (polar ins 0 rowh))   
)
(princ)
)

(defun dtr (x)
(* pi (/ x 180.0))
)

rameshaxis 发表于 2022-7-6 09:22:45

Brian先生,
 
 
我看过你的帖子,Lisp程序的洞。我希望你只解决我的问题。我想画一些圆(孔)在一条线(规线)在不同的距离。我用你的“孔lisp”写了lisp。但我写不正确。请纠正我的Lisp程序或给我新的。请。。。。。。。。。我的身份证是ramesh22338@yahoo.com
 
我的Lisp代码:
 
(定义c:hh(/行cols rowd rowv rowh rowo hole)
(setq)
cols(getint“\n输入列数(| |):”)
rowd(getdist(strcat“\n引导行:”))
rowo(getdist(strcat“\n第一个孔:”)
rowh(getdist(strcat“\n第二个孔/中心:”)
rowb(getdist(strcat“\n3孔/中心:”)
 
孔(getdist(strcat“\n孔直径”(rtos 17.5)”>:“”)
)
(if(=行nil)(setq行0))
(if(=cols nil)(setq cols 1))
(if(=行零)(setq行3))
(if(=rowh nil)(setq rowh 1))
(if(=rowb nil)(setq rowb 1))
(if(=rowo nil)(setq rowo 25))
(if(=孔零)(setq孔17.5))
(setq ins(getpoint“\n选择插入点:”)
(setq ins(极坐标ins 0 rowo))
(重复cols
 
(setq lstpnt(极坐标ins(*pi 1.5)rowd))
(entmake(列表(cons 0“圆形”)(cons 10 lstpnt)(cons 40(/孔2.0)))
 
(重复(1行)
(setq lstpntt(极性lstpnt(*pi 1.5)rowh))
(entmake(列表(cons 0“圆形”)(cons 10 2ndpnt)(cons 40(/孔2.0)))
 
(setq lstpnt(极性2ndpnt(*pi 1.5)rowb))
(entmake(列表(cons 0“圆形”)(cons 10 3rdpnt)(cons 40(/孔2.0)))
)
(setq ins(极坐标ins 0 rowh))
)
(普林斯)

SLW210 发表于 2022-7-6 09:30:01

rameshaxis,
 
请阅读代码发布指南并编辑您的帖子。
页: 1 [2]
查看完整版本: Autolisp生成孔