乐筑天下

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

[编程交流] 选择lisp

[复制链接]

18

主题

46

帖子

29

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-6 08:03:55 | 显示全部楼层 |阅读模式
假设我使用“复制”或“镜像”命令,在使用其中一个命令后创建了25个新对象。如何快速选择这25个新创建的对象?像这样的东西有Lisp程序的吗?
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:11:00 | 显示全部楼层
请检查这个线程的第二个帖子的例程。如果要在AutoLISP例程中调用偏移/复制命令,则只需根据您的情况进行调整;如果在prompter上手动完成编辑,则应将其分为两个例程,一个用于保留参考实体(最后一个实体-ENTLAST),另一个用于收集新项目。
回复

使用道具 举报

18

主题

46

帖子

29

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-6 08:20:15 | 显示全部楼层
请查看此代码:
  1. ;;*****************************************************************************
  2. ;                     LASTN.LSP V1.0 by Zoltan Toth
  3. ;    ZOTO Technologies,
  4. ;    23 Greenhills Dve,
  5. ;    Melton, 3337.
  6. ;    E-MAIL: zoltan.toth@ains.net.au
  7. ;       WWW: http://www.ains.net.au/zoto/
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  9. ; This program will select the last n objects created in a drawing where n
  10. ; is an integer input by the user. This is most useful when you create a
  11. ; number of objects with the COPY, MIRROR or ARRAY commands and you wish to
  12. ; work with the ones just created. LASTN has been written so that it can be
  13. ; used in three different ways for maximum flexibility. First, it can be
  14. ; called by itself at the "Command:" prompt and the objects so selected can
  15. ; be accessed by a later command with the "Previous" option. Second, it can
  16. ; be called transparently (with a preceding apostrophe) at a "Select
  17. ; objects:" prompt and the objects selected will be passed back to the
  18. ; waiting command. Since it can be tedious to type in the preceding
  19. ; apostrophe, it is best to incorporate this command in the menu with the
  20. ; apostrophe included to make it a quick "single pick" invokation. Thirdly,
  21. ; as the (LASTN) function is not nested within (C:LASTN), it can be called
  22. ; (with an integer argument) by other programs. As an example, to set symbol
  23. ; SS1 to a selection set containing the last 5 objects created, use:
  24. ;
  25. ; (setq SS1(lastn 5))
  26. ;
  27. ;      Any program that utilizes the (LASTN) function should, of course, check
  28. ; to see if it is already loaded and if not, load it. The following AutoLISP
  29. ; code would be satisfactory in most cases:
  30. ;
  31. ; (if(not LASTN)(load "LASTN"))
  32. ;
  33. ;      Note that although AutoCAD's "Last" option selects the last drawn
  34. ; object visible, at least partially, on screen, LASTN always selects the
  35. ; last n drawn objects, whether visible on screen or not. This includes
  36. ; objects on layers that are OFF or FROZEN. Objects on LOCKed layers are
  37. ; also selected but cannot be edited whereas objects on FROZEN or OFF layers
  38. ; can be edited. Caution: don't specify a value higher than the number of
  39. ; objects you have created in the current space (Paper or Model) since you
  40. ; last entered that space ie. changed TILEMODE - the results won't be what
  41. ; you want.
  42. ;;*****************************************************************************
  43. (defun lastn (INT2 / SS2 SSL2)             ;define function to take 1 argument
  44. (setq SS2 (ssadd))                         ;set SS2 to an empty selection set
  45. (repeat INT2                                               ;repeat INT2 times
  46. (if (entlast)
  47.   (progn
  48.    (ssadd (entlast) SS2)          ;add last undeleted object to selection set
  49.    (entdel (entlast))                           ;delete last undeleted object
  50.   )
  51. )
  52. )
  53. (setq SSL2 (1- (sslength SS2)));set SSL2 to 1 less than size of selection set
  54. (while (>= SSL2 0)              ;while SSL2 is greater than or equal to zero
  55. (entdel (ssname SS2 SSL2))         ;undelete SSL2'th object in selection set
  56. (setq SSL2 (1- SSL2))                                         ;decrement SL2
  57. )
  58. SS2                                 ;return selection set to calling function
  59. )                                                        ;end (lastn) function
  60. (defun C:loo (/ COUNT2)                                     ;define function
  61. ;set COUNT2 to number of objects
  62. (setq COUNT2 (getint "\nEnter number of objects: "))
  63. (if (= 0 (getvar "CMDACTIVE"))                 ;if no other command is active
  64. (progn                                                                 ;else
  65.   (command "._SELECT" (lastn COUNT2) "")       ;run SELECT command and (lastn)
  66.   (princ)                                                       ;exit quietly
  67. )
  68. (lastn COUNT2)                          ;call (lastn) function with argument
  69. )
  70. )

 
 
使用这个,我必须插入创建的对象的数量;我想用这样的东西,但要插入这样的东西。。。lc-上次创建,不是数字。。。。当我使用autocad中的select命令时,我说L-last,我将只选择最后创建的对象,使用类似LC-last created的东西,我想选择所有10个。。。或使用最后一个命令创建25个对象。怎样
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:25:11 | 显示全部楼层
你可以从这里开始:
  1. (setq lastItem (entlast))
  2. ;; do your processing
  3. (setq ssetItems (ssadd))
  4. (while (setq lastItem (entnext lastItem))
  5. (ssadd lastItem ssetItems)
  6. )
  7. (sssetfirst nil ssetItems)
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 08:32:43 | 显示全部楼层
也许复习一下这篇文章。。。
 
M、 R。
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:38:48 | 显示全部楼层
一条注释,它将从图形中收集所有相同的实体,而不仅仅是在最后一个操作中添加的实体。
回复

使用道具 举报

18

主题

46

帖子

29

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-6 08:40:08 | 显示全部楼层
我只想选择用最后一个命令创建的实体。。。这就是想法。。。
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 08:49:49 | 显示全部楼层
可以自由修改以满足您的需要:
  1. (defun c:CopyMWithSelect( / lastItem ssetItems )
  2. (setq lastItem (entlast))
  3. (command "_COPY" pause "" "_M")
  4. (while (> (getvar "CMDACTIVE") 0)
  5. (command pause)
  6. )
  7. (setq ssetItems (ssadd))
  8. (while (setq lastItem (entnext lastItem))
  9. (ssadd lastItem ssetItems)
  10. )
  11. (sssetfirst nil ssetItems)
  12. (princ)
  13. )
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 08:54:26 | 显示全部楼层
我的一个老朋友:http://forums.augi.com/showthread.php?73343-选择“上一个”,然后选择“复制”“旋转”
回复

使用道具 举报

18

主题

46

帖子

29

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-6 09:02:21 | 显示全部楼层
哇,太棒了!谢谢你,irneb!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-9 21:43 , Processed in 0.589679 second(s), 72 queries .

© 2020-2025 乐筑天下

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