乐筑天下

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

[编程交流] LISP使用ce复制多段线

[复制链接]

3

主题

7

帖子

4

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 23:38:57 | 显示全部楼层 |阅读模式
你好
 
在阅读了很长一段时间(并从中受益匪浅)之后,我的第一个帖子来了:
我需要一个例程来创建许多具有相同起点的多段线。我厌倦了总是把第一分移回正确的起点。
 
这是我的解决方案,有点像复制-拉伸混合。这能以更优雅的方式实现吗?
 
 
  1. (defun c:cfp ( / i ss plist_o ss_n elist_t plist_t pcount bpoint)
  2. (vl-load-com)
  3. ;get points of original polyline
  4. (setq
  5.    ss (car(entsel "\nSelect Polyline to copy."))
  6.    plist_o (vl-remove-if-not
  7.      (function (lambda (pt) (= (car pt) 10)))
  8.      (entget ss)
  9.              )
  10. )
  11. ;get userinput on how many points should be fixed and basepoint for multiple copies
  12. (initget 4)
  13. (setq
  14. pcount (getint "\nHow many points should be fixed? <1>"))
  15. (if (= pcount nil) (setq pcount 1))
  16. (setq bpoint (getpoint "\nSelect basepoint"))
  17. (while (not nil)
  18. ;perform copy and get the points of the temporal polyline
  19. (command "_copy" ss "" bpoint pause)
  20. (setq
  21.    ss_n (entlast)
  22.    elist_t (entget ss_n)
  23.    plist_t (vl-remove-if-not
  24.                (function (lambda (pt) (= (car pt) 10)))
  25.                (entget ss_n)
  26.             )
  27.   )
  28. ;change the fixed points of the temporal polyline back to the
  29. ;original points and draw the final polyline
  30. (setq i 0)
  31. (repeat pcount
  32.    (setq elist_t
  33.      (subst
  34.        (nth i plist_o)
  35.        (nth i plist_t)
  36.        elist_t
  37.      )
  38.   )
  39.   (setq i (1+ i))
  40. )
  41. (entmod elist_t)
  42. )
  43. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 00:28 , Processed in 0.797319 second(s), 54 queries .

© 2020-2025 乐筑天下

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