乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: Impala62

[编程交流] Autolisp生成孔

[复制链接]

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:19:13 | 显示全部楼层
我试图在你的代码中添加一行代码,看看我是否能更好地理解这门语言。
 
我想将这段代码合并到另一个lisp例程中,但我想首先尝试在代码中添加一行简单的代码。
 
添加了粗体代码。
 
  1. (defun c:hol ( / rows cols rowd rowv rowh hole )
  2. [b]    (setq ins (getpoint "\nInsertion Point"))
  3.   (setq len1 (getpoint "\nLength of Line"))[/b]
  4. (setq rows (getint "\nEnter the number of rows (---) <2>: ")
  5.        cols (getint "\nEnter the number of columns (|||) <3>: ")
  6.        rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
  7.        rowv (getdist (strcat "\nVertical center / center <" (rtos 50) ">: "))
  8.        rowh (getdist (strcat "\nHorizontal center / center <" (rtos 50) ">: "))
  9.        hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
  10. )
  11. (if (= rows nil)(setq rows 2))
  12. (if (= cols nil)(setq cols 3))
  13. (if (= rowd nil)(setq rowd 25))
  14. (if (= rowh nil)(setq rowh 50))
  15. (if (= rowv nil)(setq rowv 25))
  16. (if (= hole nil)(setq hole 17.5))
  17. [b]   (setq ins (getpoint "\nSelect insertion point: "))
  18. (setq pt02 (polar ins (dtr 90.0)  len1 )) [/b]
  19. (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
  20. (repeat cols
  21.    (setq lstpnt (polar ins (* pi 1.5) rowd))
  22. [b] (command "line" ins pt02 "") [/b]
  23.    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  24.    (repeat (1- rows)
  25.      (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  26.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  27.    )
  28.    (setq ins (polar ins 0 rowh))   
  29. )
  30. (princ)
  31. )
  32. (defun dtr (x)
  33. (* pi (/ x 180.0))
  34. )
回复

使用道具 举报

0

主题

5

帖子

5

银币

初来乍到

Rank: 1

铜币
0
发表于 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))
)
(普林斯)
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-6 09:30:01 | 显示全部楼层
rameshaxis,
 
请阅读代码发布指南并编辑您的帖子。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-7 08:50 , Processed in 0.344873 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表