乐筑天下

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

[编程交流] 需要帮助升级我的LISP

[复制链接]

7

主题

25

帖子

18

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 15:54:45 | 显示全部楼层 |阅读模式
您好,这里有一个LISP例程,用于确定某个多边形(通常是多段线)的比例。程序是这样的,用户将单击多边形的最北端、最南端、最东端和最西端点,然后确定比例。有没有升级的方法,比如只需单击多段线,就可以确定比例?没有更多的极端点点击。
 
以下是lisp例程:
 
  1. (defun c:gs ( / xn xs xw xe diff miff)
  2. (defun roundup100 ( x )
  3.    (if (equal 0.0 (rem x 100) 1e-
  4.        (atoi (rtos x 2 0))
  5.        (* 100 (fix (1+ (/ x 100.0))))
  6.       )
  7. )
  8. (defun roundup1000 ( y )
  9.    (if (equal 0.0 (rem y 1000) 1e-
  10.        (atoi (rtos y 2 0))
  11.        (* 1000 (fix (1+ (/ y 1000.0))))
  12. )
  13. )
  14. (setq xn (getpoint "\nPick the point on the extreme north of the lot boundary:"))
  15. (setq xs (getpoint xn "\nPick the point on the extreme south of the lot boundary:"))
  16. (setq xe (getpoint "\
  17. Pick the point on the extreme east of the lot boundary:"))
  18. (setq xw (getpoint "\
  19. Pick the point on the extreme west of the lot boundary:" xe))
  20. (setq diff (/ (- (cadr xn) (cadr xs)) 0.3))
  21. (setq miff (/ (- (car xe) (car xw)) 0.3))
  22. (if (< miff diff)
  23. (progn
  24. (if (<= diff 800)
  25. (princ (strcat "\n\nPlotting Scale is 1: " (rtos (roundup100 diff) 2 0)))
  26. )
  27. (if (> diff 800)
  28. (princ (strcat "\n\nPlotting Scale is 1: " (rtos (roundup1000 diff) 2 0)))
  29. )
  30. )
  31. )
  32. (if (> miff diff)
  33. (progn
  34. (if (<= miff 800)
  35. (princ (strcat "\n\nPlotting Scale is 1: " (rtos (roundup100 miff) 2 0)))
  36. )
  37. (if (> miff 800)
  38. (princ (strcat "\n\nPlotting Scale is 1: " (rtos (roundup1000 diff) 2 0)))
  39. )
  40. )
  41. )
  42. (princ)
  43. )

 
提前感谢
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 16:33:34 | 显示全部楼层
寻找:
 
  1. (vla-getboundingbox (vlax-ename->vla-object pline-ename) 'lowerleftpoint 'upperrightpoint)
  2. (mapcar 'set '(lowerleftpoint upperrightpoint) (mapcar 'safearray-value (list lowerleftpoint upperrightpoint)))

 
从变量:通过(vla getboundingbox)方法定义的lowerleftpoint和upperrightpoint,您应该能够获得例程所需的极值点。。。因此,在正确实现后,只有拾取或选择多段线或任何其他主题实体才能得到所需的结果。。。
 
HTH。,M、 R。
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:36:34 | 显示全部楼层
我想这就是你想要的。。。你的miff diff逻辑让我有点困惑。
  1. (defun c:gs (/ roundupto d e ll ur)
  2. (defun roundupto (x n)
  3.    (if        (equal 0.0 (rem x n) 1e-
  4.      (atoi (rtos x 2 0))
  5.      (* n (fix (1+ (/ x n))))
  6.    )
  7. )
  8. (if (setq e (car (entsel "\nPick something: ")))
  9.    (progn (vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
  10.    (mapcar 'set '(ll ur) (mapcar 'vlax-safearray->list (list ll ur)))
  11.    (setq d (apply 'max (mapcar 'abs (list (apply '- ll) (apply '- ur)))))
  12.    (alert (strcat "\n\nPlotting Scale is 1: "
  13.                   (rtos        (roundupto d
  14.                                    (if (<= (/ d 0.3) 800)
  15.                                      100.
  16.                                      1000.
  17.                                    )
  18.                         )
  19.                         2
  20.                         0
  21.                   )
  22.           )
  23.    )
  24.    )
  25. )
  26. (princ)
  27. )
回复

使用道具 举报

7

主题

25

帖子

18

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:58:10 | 显示全部楼层
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 13:08 , Processed in 2.235627 second(s), 61 queries .

© 2020-2025 乐筑天下

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