乐筑天下

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

[编程交流] 需要斜率lisp

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:48:54 | 显示全部楼层
好吧,我忍不住。。。为了让你摆脱痛苦:
 
但是请阅读评论
 
  1. (defun c:hc  (/ *error* vlst ovar cBlk tmp1 tmp2 tmp3 tmp4 blkpt)
  2. ; Error Handler
  3. (defun *error* (msg)
  4.    (if ovar (mapcar 'setvar vlst ovar))  ; Return System Variables
  5.    (if (not (member msg '("Function cancelled" "quit / exit abort")))
  6.      (princ (strcat "\n<< Error: " msg " >>")))  ; Print Error Message
  7.    (princ))
  8. ; Collect and Set System Variables
  9. (setq vlst '("CMDECHO" "OSMODE")
  10.        ovar (mapcar 'getvar vlst))
  11. (mapcar 'setvar vlst '(0 0))
  12. ; Set Defaults
  13. (or hc$slp:def (setq hc$slp:def 1))
  14. (or hc$cop:def (setq hc$cop:def 1))
  15. (or hc$spc:def (setq hc$spc:def 1))
  16. (or hc$dir:def (setq hc$dir:def "X"))
  17. ; Get Block to Copy
  18. (if (and (setq cBlk (car (entsel "\nSelect Block: ")))
  19.           (eq "INSERT" (cdr (assoc 0 (entget cBlk)))))
  20.    (progn
  21. ; Get User Input
  22.      (initget 6)
  23.      (setq tmp1 (getreal (strcat "\nSpecify Slope <" (rtos hc$slp:def) ">  1:")))
  24.      (or (not tmp1) (setq hc$slp:def tmp1))
  25.      (initget 6)
  26.      (setq tmp2 (getint (strcat "\nSpecify Number of Copies <" (itoa hc$cop:def) "> : ")))
  27.      (or (not tmp2) (setq hc$cop:def tmp2))
  28.      (initget 6)
  29.      (setq tmp3 (getreal (strcat "\nSpecify Spacing <" (rtos hc$spc:def) "> : ")))
  30.      (or (not tmp3) (setq hc$spc:def tmp3))
  31.      (initget "X Y")
  32.      (setq tmp4 (getkword (strcat "\nSpecify Direction [X/Y] <" hc$dir:def "> : ")))
  33.      (or (not tmp4) (setq hc$dir:def tmp4))
  34. ; Get Block Insertion Point Information and Initiate Counter
  35.      (setq blkpt (cdr (assoc 10 (entget cBlk)))
  36.            i     1)
  37. ; Copy the Block a Number of Times
  38.      (repeat hc$cop:def
  39.        (command "_copy" cBlk "" blkpt)
  40.        (cond ((eq "X" hc$dir:def)
  41.               (command
  42.                 (list (+ (* i hc$spc:def) (car blkpt))
  43.                       (cadr blkpt)
  44.                       (+ (* i hc$spc:def (/ 1 hc$slp:def)) (caddr blkpt)))))
  45.              ((eq "Y" hx$dir:def)
  46.               (command
  47.                 (car blkpt)
  48.                 (list (+ (* i hc$spc:def) (cadr blkpt))
  49.                       (+ (* i hc$spc:def (/ 1 hc$slp:def)) (caddr blkpt))))))
  50.        (command)
  51.        (setq i (1+ i))))
  52.    ; Else No Block was Selected
  53.    (princ "\n<!> No Block Selected <!>"))
  54. ; Return Sys Vars Back
  55. (mapcar 'setvar vlst ovar)
  56. ; Exit Cleanly
  57. (princ))
回复

使用道具 举报

5

主题

42

帖子

39

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 09:52:22 | 显示全部楼层
好的,笔记本电脑在家里,安装好了。我将尝试在示例图形上编写代码。
 
谢谢你的时间和努力。
 
这是一个快速绘制我试图做什么,但在一个更大的规模。
 
再次感谢!
阻止移动。图纸
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:54:01 | 显示全部楼层
 
好的,我只能打开2004或更早的格式。
回复

使用道具 举报

5

主题

42

帖子

39

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 09:57:25 | 显示全部楼层
很抱歉。
阻止移动。图纸
回复

使用道具 举报

5

主题

42

帖子

39

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 10:00:56 | 显示全部楼层
我确实尝试了你的代码,它确实有效,但我正在试图找出海拔变化如此剧烈的原因。我在48和斜率的x上做了一个拷贝。125,看起来它的海拔变化了125英尺。但这将比我的方式快得多。
 
再次感谢李
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:04:04 | 显示全部楼层
我将输入的高程设置为,例如8代表0.125,4代表0.25等等
回复

使用道具 举报

5

主题

42

帖子

39

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 10:08:20 | 显示全部楼层
是这样吗。125/每12。我尝试了更高的数字,我正在接近使用75,但还没有安静。
 
此外,它只允许从原始块向一个方向移动。这没什么大不了的,我只需要记住把原来的积木放在那里。
 
谢谢李
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:10:12 | 显示全部楼层
现在可以输入0.125作为坡度:
 
  1. (defun c:hc  (/ *error* vlst ovar cBlk tmp1 tmp2 tmp3 tmp4 blkpt)
  2. ; Error Handler
  3. (defun *error* (msg)
  4.    (if ovar (mapcar 'setvar vlst ovar))  ; Return System Variables
  5.    (if (not (member msg '("Function cancelled" "quit / exit abort")))
  6.      (princ (strcat "\n<< Error: " msg " >>")))  ; Print Error Message
  7.    (princ))
  8. ; Collect and Set System Variables
  9. (setq vlst '("CMDECHO" "OSMODE")
  10.        ovar (mapcar 'getvar vlst))
  11. (mapcar 'setvar vlst '(0 0))
  12. ; Set Defaults
  13. (or hc$slp:def (setq hc$slp:def 1))
  14. (or hc$cop:def (setq hc$cop:def 1))
  15. (or hc$spc:def (setq hc$spc:def 1))
  16. (or hc$dir:def (setq hc$dir:def "X"))
  17. ; Get Block to Copy
  18. (if (and (setq cBlk (car (entsel "\nSelect Block: ")))
  19.           (eq "INSERT" (cdr (assoc 0 (entget cBlk)))))
  20.    (progn
  21. ; Get User Input
  22.      (initget 6)
  23.      (setq tmp1 (getreal (strcat "\nSpecify Slope <" (rtos hc$slp:def) "> : ")))
  24.      (or (not tmp1) (setq hc$slp:def tmp1))
  25.      (initget 6)
  26.      (setq tmp2 (getint (strcat "\nSpecify Number of Copies <" (itoa hc$cop:def) "> : ")))
  27.      (or (not tmp2) (setq hc$cop:def tmp2))
  28.      (initget 6)
  29.      (setq tmp3 (getreal (strcat "\nSpecify Spacing <" (rtos hc$spc:def) "> : ")))
  30.      (or (not tmp3) (setq hc$spc:def tmp3))
  31.      (initget "X Y")
  32.      (setq tmp4 (getkword (strcat "\nSpecify Direction [X/Y] <" hc$dir:def "> : ")))
  33.      (or (not tmp4) (setq hc$dir:def tmp4))
  34. ; Get Block Insertion Point Information and Initiate Counter
  35.      (setq blkpt (cdr (assoc 10 (entget cBlk)))
  36.            i     1)
  37. ; Copy the Block a Number of Times
  38.      (repeat hc$cop:def
  39.        (command "_copy" cBlk "" blkpt)
  40.        (cond ((eq "X" hc$dir:def)
  41.               (command
  42.                 (list (+ (* i hc$spc:def) (car blkpt))
  43.                       (cadr blkpt)
  44.                       [b][color=Red](+ (* i hc$spc:def hc$slp:def) (caddr blkpt))[/color][/b][color=Red][color=Black])[/color][/color]))
  45.              ((eq "Y" hx$dir:def)
  46.               (command
  47.                 (car blkpt)
  48.                 (list (+ (* i hc$spc:def) (cadr blkpt))
  49.                       [b][color=Red](+ (* i hc$spc:def hc$slp:def) (caddr blkpt))[/color][/b][color=Red][color=Black])[/color][/color])))
  50.        (command)
  51.        (setq i (1+ i))))
  52.    ; Else No Block was Selected
  53.    (princ "\n<!> No Block Selected <!>"))
  54. ; Return Sys Vars Back
  55. (mapcar 'setvar vlst ovar)
  56. ; Exit Cleanly
  57. (princ))
Z值由红色部分计算^^
 

 
Z=(基准Z)+(计数器*间距*斜率)
回复

使用道具 举报

5

主题

42

帖子

39

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 10:15:29 | 显示全部楼层
这一个更接近,但仍然没有得到正确的坡度。当我把一个斜坡。125在240次跑步中上升30,在240次跑步中只应上升2.5。我知道你说它是用红色计算的,但我没有看到任何数字,所以我甚至可以开始玩你的脚本。
 
谢谢李
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:17:43 | 显示全部楼层
 
它不应该上升30吗?0.125 x 240=30?
 
你怎么得到2.5分?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 03:12 , Processed in 0.745505 second(s), 81 queries .

© 2020-2025 乐筑天下

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