乐筑天下

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

[编程交流] Autolisp生成孔

[复制链接]

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:26:53 | 显示全部楼层 |阅读模式
大家好,
 
I 2D结构钢详图。
我正在寻找一个lisp,将创建孔与偏置规线孔直径孔数等选项。
 
有什么东西在外面或附近吗?
 
账单
回复

使用道具 举报

6

主题

48

帖子

44

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 08:32:09 | 显示全部楼层
这是一个快速程序。几年前,当我详细介绍结构钢时,我有一个更好的方法。没有错误捕获,可以改进。它应该可以帮助你开始。
 
布瑞恩
 
  1. (defun c:holes ( / rows cols rowd rowv rowh hole )
  2. (setq rows (getint "\nEnter the number of rows (---) <1>: ")
  3.        cols (getint "\nEnter the number of columns (|||) <1>: ")
  4.        rowd (getdist (strcat "\nBeam guage <" (itoa 3) ">: "))
  5.        rowv (getdist (strcat "\nVertical center / center <" (itoa 3) ">: "))
  6.        rowh (getdist (strcat "\nHorizontal center / center <" (itoa 4) ">: "))
  7.        hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
  8. )
  9. (if (= rows nil)(setq rows 1))
  10. (if (= cols nil)(setq cols 1))
  11. (if (= rowd nil)(setq rowd 3))
  12. (if (= rowh nil)(setq rowh 4))
  13. (if (= rowv nil)(setq rowv 3))
  14. (if (= hole nil)(setq hole 0.8125))
  15. (setq ins (getpoint "\nSelect insertion point: "))
  16. (repeat cols
  17.    (setq lstpnt (polar ins (* pi 1.5) rowd))
  18.    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  19.    (repeat (1- rows)
  20.      (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  21.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  22.    )
  23.    (setq ins (polar ins 0 rowh))   
  24. )
  25. (princ)
  26. )
回复

使用道具 举报

0

主题

39

帖子

39

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 08:37:42 | 显示全部楼层
谢谢brian。。。。希望你不介意我拿一份。。
美好的易于理解的常规
回复

使用道具 举报

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:44:45 | 显示全部楼层
谢谢你的代码。
 
它工作得很好。
现在,如何添加钢边缘到第一列/行孔中心的偏移?
 
账单
回复

使用道具 举报

6

主题

48

帖子

44

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 08:48:03 | 显示全部楼层
  1. (defun c:holes ( / rows cols rowd rowv rowh hole )
  2. (setq rows (getint "\nEnter the number of rows (---) <1>: ")
  3.        cols (getint "\nEnter the number of columns (|||) <1>: ")
  4.        rowd (getdist (strcat "\nBeam guage <" (itoa 3) ">: "))
  5.        rowv (getdist (strcat "\nVertical center / center <" (itoa 3) ">: "))
  6.        rowh (getdist (strcat "\nHorizontal center / center <" (itoa 4) ">: "))
  7.        hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
  8. )
  9. (if (= rows nil)(setq rows 1))
  10. (if (= cols nil)(setq cols 1))
  11. (if (= rowd nil)(setq rowd 3))
  12. (if (= rowh nil)(setq rowh 4))
  13. (if (= rowv nil)(setq rowv 3))
  14. (if (= hole nil)(setq hole 0.8125))
  15. (setq ins (getpoint "\nSelect insertion point: "))
  16. [color=red][/color]
  17. [color=lime]  ' Add this[/color]
  18. [color=red]  (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))[/color]
  19. (repeat cols
  20.    (setq lstpnt (polar ins (* pi 1.5) rowd))
  21.    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  22.    (repeat (1- rows)
  23.      (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  24.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  25.    )
  26.    (setq ins (polar ins 0 rowh))   
  27. )
  28. (princ)
  29. )

我认为这可能管用。如果不是你想要的,给我一个你想要的cad文件,我会看看我能做什么。
 
布瑞恩
回复

使用道具 举报

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 08:53:56 | 显示全部楼层
谢谢Brian,
 
我发现它还不起作用。
 
我想做的是,一旦所有的输入都完成了,我需要的最后一件事是输入从插入点的偏移距离。
 
比尔·斯凯尔特马
回复

使用道具 举报

6

主题

48

帖子

44

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 09:00:43 | 显示全部楼层
没问题。我希望这有帮助。
 
 
这是绘制端点连接的修改版本。我有一个更完整的详细计划,但我通常收费。(对不起!)
 
布瑞恩
  1. (defun c:holes_center ( / rows cols rowd rowv rowh hole )
  2. (setq rows (getint "\nEnter the number of rows (---) <1>: ")
  3.        cols (getint "\nEnter the number of columns (|||) <1>: ")
  4.        rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
  5.        rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
  6.        rowh (getdist (strcat "\nHorizontal center / center <" (rtos 4) ">: "))
  7.        hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
  8. )
  9. (if (= rows nil)(setq rows 1))
  10. (if (= cols nil)(setq cols 1))
  11. (if (= rowd nil)(setq rowd 3))
  12. (if (= rowh nil)(setq rowh 4))
  13. (if (= rowv nil)(setq rowv 3))
  14. (if (= hole nil)(setq hole 0.8125))
  15. (setq ins (getpoint "\nSelect insertion point: "))
  16. (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
  17. (repeat cols
  18.    (setq lstpnt (polar ins (* pi 1.5) rowd))
  19.    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  20.    (repeat (1- rows)
  21.      (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  22.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  23.    )
  24.    (setq ins (polar ins 0 rowh))   
  25. )
  26. (princ)
  27. )
  28. (defun c:holes_end ( / dir rows rowd rowh rowv rowo hole )
  29. (initget 0 "Left Right")
  30. (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
  31.        rows (getint "\nEnter the number of rows (---) <1>: ")
  32.        rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
  33.        rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
  34.        rowo (getdist (strcat "\nEndge offset <" (rtos 1.5) ">: "))
  35.        hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
  36. )
  37. (if (= dir  nil)(setq dir "Left"))
  38. (if (= rows nil)(setq rows 1))
  39. (if (= rowd nil)(setq rowd 3))
  40. (if (= rowh nil)(setq rowh 4))
  41. (if (= rowv nil)(setq rowv 3))
  42. (if (= rowo nil)(setq rowo 1.5))
  43. (if (= hole nil)(setq hole 0.8125))
  44. (setq ins (getpoint "\nSelect insertion point: "))
  45. (if (= dir "Left")
  46.    (progn
  47.      (setq ins (polar ins 0 rowo)
  48.            lstpnt (polar ins (* pi 1.5) rowd)
  49.      )
  50.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  51.      (repeat (1- rows)
  52.        (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  53.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  54.      )
  55.    )
  56.    (progn
  57.      (setq ins (polar ins pi rowo)
  58.            lstpnt (polar ins (* pi 1.5) rowd)
  59.      )
  60.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  61.      (repeat (1- rows)
  62.        (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  63.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  64.      )
  65.    )
  66. )
  67. (princ)
  68. )

092655ws3il6hxnshplilg.jpg
回复

使用道具 举报

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:03:05 | 显示全部楼层
谢谢你的密码,
我试图将列函数也添加到holes\u end,但我知道我遗漏了一些东西。加粗的蓝色是我添加的代码。
 
我接近了吗?
 
  1. (defun c:holes_center ( / rows cols rowd rowv rowh hole )
  2. (setq rows (getint "\nEnter the number of rows (---) <1>: ")
  3.        cols (getint "\nEnter the number of columns (|||) <1>: ")
  4.        rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
  5.        rowv (getdist (strcat "\nVertical center / center <" (rtos 30) ">: "))
  6.        rowh (getdist (strcat "\nHorizontal center / center <" (rtos 4) ">: "))
  7.        hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
  8. )
  9. (if (= rows nil)(setq rows 1))
  10. (if (= cols nil)(setq cols 1))
  11. (if (= rowd nil)(setq rowd 30))
  12. (if (= rowh nil)(setq rowh 4))
  13. (if (= rowv nil)(setq rowv 30))
  14. (if (= hole nil)(setq hole 17.5))
  15. (setq ins (getpoint "\nSelect insertion point: "))
  16. (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))
  17. (repeat cols
  18.    (setq lstpnt (polar ins (* pi 1.5) rowd))
  19.    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  20.    (repeat (1- rows)
  21.      (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  22.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  23.    )
  24.    (setq ins (polar ins 0 rowh))   
  25. )
  26. (princ)
  27. )
  28. (defun c:holes_end ( / dir rows [color=magenta][b]cols[/b][/color] rowd rowh rowv rowo hole )
  29. (initget 0 "Left Right")
  30. (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
  31.        rows (getint "\nEnter the number of rows (---) <1>: ")
  32. [color=magenta][b]        cols (getint "\nEnter the number of columns (|||) <1>: ")[/b][/color]
  33.        rowd (getdist (strcat "\nBeam guage <" (rtos 30) ">: "))
  34.        rowv (getdist (strcat "\nVertical center / center <" (rtos 30) ">: "))
  35.        rowo (getdist (strcat "\nEndge offset <" (rtos 30) ">: "))
  36.        hole (getdist (strcat "\nHole diameter " (rtos 17.5) ">: "))
  37. )
  38. (if (= dir  nil)(setq dir "Left"))
  39. (if (= rows nil)(setq rows 1))
  40. [b][color=magenta]  (if (= cols nil)(setq cols 1))[/color][/b]
  41. (if (= rowd nil)(setq rowd 30))
  42. (if (= rowh nil)(setq rowh 4))
  43. (if (= rowv nil)(setq rowv 30))
  44. (if (= rowo nil)(setq rowo 30))
  45. (if (= hole nil)(setq hole 17.5))
  46. (setq ins (getpoint "\nSelect insertion point: "))
  47. [color=magenta][b]  (if (> cols 1)(setq ins (polar ins pi (/ (* (1- cols) rowh) 2.0))))[/b][/color]
  48. [b][color=magenta]  (repeat cols[/color][/b]
  49. [b][color=magenta]    (setq lstpnt (polar ins (* pi 1.5) rowd))[/color][/b]
  50. [b][color=magenta]    (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))[/color][/b]
  51. (if (= dir "Left")
  52.    (progn
  53.      (setq ins (polar ins 0 rowo)
  54.            lstpnt (polar ins (* pi 1.5) rowd)
  55.      )
  56.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  57.      (repeat (1- rows)
  58.        (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  59.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  60.      )
  61.    )
  62.    (progn
  63.      (setq ins (polar ins pi rowo)
  64.            lstpnt (polar ins (* pi 1.5) rowd)
  65.      )
  66.      (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  67.      (repeat (1- rows)
  68.        (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  69.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  70.      )
  71.    )
  72. )
  73. (princ)
  74. )

 
回复

使用道具 举报

6

主题

48

帖子

44

银币

初来乍到

Rank: 1

铜币
30
发表于 2022-7-6 09:07:36 | 显示全部楼层
试试这个。
布瑞恩
  1. (defun c:holes_end ( / cols dir rows rowd rowh rowv rowo hole )
  2. (initget 0 "Left Right")
  3. (setq dir  (getkword "\nEnd of beam (Left/Right) <L>: ")
  4.        rows (getint "\nEnter the number of rows (---) <1>: ")
  5.        cols (getint "\nEnter the number of columns (|||) <1>: ")
  6.        rowd (getdist (strcat "\nBeam guage <" (rtos 3) ">: "))
  7.        rowv (getdist (strcat "\nVertical center / center <" (rtos 3) ">: "))
  8.        rowh (getdist (strcat "\nHorizontal center / center <" (rtos 3) ">: "))
  9.        rowo (getdist (strcat "\nEndge offset <" (rtos 1.5) ">: "))
  10.        hole (getdist (strcat "\nHole diameter " (rtos 0.8125) ">: "))
  11. )
  12. (if (= dir  nil)(setq dir "Left"))
  13. (if (= rows nil)(setq rows 1))
  14. (if (= cols nil)(setq cols 1))
  15. (if (= rowd nil)(setq rowd 3))
  16. (if (= rowh nil)(setq rowh 3))
  17. (if (= rowv nil)(setq rowv 3))
  18. (if (= rowo nil)(setq rowo 1.5))
  19. (if (= hole nil)(setq hole 0.8125))
  20. (setq ins (getpoint "\nSelect insertion point: "))
  21. (if (= dir "Left")
  22.    (progn
  23.      (setq ins (polar ins 0 rowo))
  24.      (repeat cols
  25.        (setq lstpnt (polar ins (* pi 1.5) rowd))
  26.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  27.        (repeat (1- rows)
  28.          (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  29.          (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  30.        )
  31.        (setq ins (polar ins 0 rowh))
  32.      )
  33.    )
  34.    (progn
  35.      (setq ins (polar ins pi rowo))
  36.      (repeat cols
  37.        (setq lstpnt (polar ins (* pi 1.5) rowd))
  38.        (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  39.        (repeat (1- rows)
  40.          (setq lstpnt (polar lstpnt (* pi 1.5) rowv))
  41.          (entmake (list (cons 0 "circle")(cons 10 lstpnt)(cons 40 (/ hole 2.0))))
  42.        )
  43.        (setq ins (polar ins pi rowh))
  44.      )
  45.    )
  46. )
  47. (princ)
  48. )
回复

使用道具 举报

2

主题

8

帖子

6

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 09:13:14 | 显示全部楼层
谢谢Brian,
 
它工作得很好。
 
最后一个请求。我理解如果你说不,你在这里帮了很多忙。
 
如果我想让用户输入列,他们可以选择设置一系列列,该怎么办。
 
我经常使用角钢,并且在长度方向上有很多孔。
 
因此,用户可以选择1或2行、波束规、孔径。,但被触发以请求第一偏移、第二偏移、第三偏移
 
再次感谢。
 
账单
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 09:02 , Processed in 0.340496 second(s), 74 queries .

© 2020-2025 乐筑天下

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