transcad 发表于 2022-7-6 08:03:55

选择lisp

假设我使用“复制”或“镜像”命令,在使用其中一个命令后创建了25个新对象。如何快速选择这25个新创建的对象?像这样的东西有Lisp程序的吗?

MSasu 发表于 2022-7-6 08:11:00

请检查这个线程的第二个帖子的例程。如果要在AutoLISP例程中调用偏移/复制命令,则只需根据您的情况进行调整;如果在prompter上手动完成编辑,则应将其分为两个例程,一个用于保留参考实体(最后一个实体-ENTLAST),另一个用于收集新项目。

transcad 发表于 2022-7-6 08:20:15

请查看此代码:
;;*****************************************************************************
;                     LASTN.LSP V1.0 by Zoltan Toth
;    ZOTO Technologies,
;    23 Greenhills Dve,
;    Melton, 3337.
;    E-MAIL: zoltan.toth@ains.net.au
;       WWW: http://www.ains.net.au/zoto/
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This program will select the last n objects created in a drawing where n
; is an integer input by the user. This is most useful when you create a
; number of objects with the COPY, MIRROR or ARRAY commands and you wish to
; work with the ones just created. LASTN has been written so that it can be
; used in three different ways for maximum flexibility. First, it can be
; called by itself at the "Command:" prompt and the objects so selected can
; be accessed by a later command with the "Previous" option. Second, it can
; be called transparently (with a preceding apostrophe) at a "Select
; objects:" prompt and the objects selected will be passed back to the
; waiting command. Since it can be tedious to type in the preceding
; apostrophe, it is best to incorporate this command in the menu with the
; apostrophe included to make it a quick "single pick" invokation. Thirdly,
; as the (LASTN) function is not nested within (C:LASTN), it can be called
; (with an integer argument) by other programs. As an example, to set symbol
; SS1 to a selection set containing the last 5 objects created, use:
;
; (setq SS1(lastn 5))
;
;      Any program that utilizes the (LASTN) function should, of course, check
; to see if it is already loaded and if not, load it. The following AutoLISP
; code would be satisfactory in most cases:
;
; (if(not LASTN)(load "LASTN"))
;
;      Note that although AutoCAD's "Last" option selects the last drawn
; object visible, at least partially, on screen, LASTN always selects the
; last n drawn objects, whether visible on screen or not. This includes
; objects on layers that are OFF or FROZEN. Objects on LOCKed layers are
; also selected but cannot be edited whereas objects on FROZEN or OFF layers
; can be edited. Caution: don't specify a value higher than the number of
; objects you have created in the current space (Paper or Model) since you
; last entered that space ie. changed TILEMODE - the results won't be what
; you want.
;;*****************************************************************************
(defun lastn (INT2 / SS2 SSL2)             ;define function to take 1 argument
(setq SS2 (ssadd))                         ;set SS2 to an empty selection set
(repeat INT2                                             ;repeat INT2 times
(if (entlast)
(progn
   (ssadd (entlast) SS2)          ;add last undeleted object to selection set
   (entdel (entlast))                           ;delete last undeleted object
)
)
)
(setq SSL2 (1- (sslength SS2)));set SSL2 to 1 less than size of selection set
(while (>= SSL2 0)            ;while SSL2 is greater than or equal to zero
(entdel (ssname SS2 SSL2))         ;undelete SSL2'th object in selection set
(setq SSL2 (1- SSL2))                                       ;decrement SL2
)
SS2                                 ;return selection set to calling function
)                                                      ;end (lastn) function
(defun C:loo (/ COUNT2)                                     ;define function
;set COUNT2 to number of objects
(setq COUNT2 (getint "\nEnter number of objects: "))
(if (= 0 (getvar "CMDACTIVE"))               ;if no other command is active
(progn                                                               ;else
(command "._SELECT" (lastn COUNT2) "")       ;run SELECT command and (lastn)
(princ)                                                       ;exit quietly
)
(lastn COUNT2)                        ;call (lastn) function with argument
)
)

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

MSasu 发表于 2022-7-6 08:25:11

你可以从这里开始:
(setq lastItem (entlast))
;; do your processing
(setq ssetItems (ssadd))
(while (setq lastItem (entnext lastItem))
(ssadd lastItem ssetItems)
)
(sssetfirst nil ssetItems)

marko_ribar 发表于 2022-7-6 08:32:43

也许复习一下这篇文章。。。
 
M、 R。

MSasu 发表于 2022-7-6 08:38:48

一条注释,它将从图形中收集所有相同的实体,而不仅仅是在最后一个操作中添加的实体。

transcad 发表于 2022-7-6 08:40:08

我只想选择用最后一个命令创建的实体。。。这就是想法。。。

MSasu 发表于 2022-7-6 08:49:49

可以自由修改以满足您的需要:
(defun c:CopyMWithSelect( / lastItem ssetItems )
(setq lastItem (entlast))
(command "_COPY" pause "" "_M")
(while (> (getvar "CMDACTIVE") 0)
(command pause)
)
(setq ssetItems (ssadd))
(while (setq lastItem (entnext lastItem))
(ssadd lastItem ssetItems)
)
(sssetfirst nil ssetItems)
(princ)
)

irneb 发表于 2022-7-6 08:54:26

我的一个老朋友:http://forums.augi.com/showthread.php?73343-选择“上一个”,然后选择“复制”“旋转”

transcad 发表于 2022-7-6 09:02:21

哇,太棒了!谢谢你,irneb!
页: [1] 2
查看完整版本: 选择lisp