TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on April 04, 2007, 08:18:01 PM
-
Hello everybody,
I wonder if there is a way to get all new entities made by a copy command, like i do with a single entity:
(command "copy" en "" pt ptn)
(setq en1 (entlast))
How can I get ss1 when i copy ss?
Thanks in Advance
Bernd
-
If you look for the last entity in the database before the copy command, you can find all new created entities with entnext.
(setq last1 (entlast))
(command "._copy" en "" pt ptn)
(setq ss1 (collect last1))
(defun collect (el / ex ss)
(setq ex (entnext el)
ss (ssadd ex (ssadd)))
(setq ex (entnext ex))
(while ex
(setq ss (ssadd ex ss) ex (entnext ex))
)
ss
)
-
http://www.theswamp.org/index.php?topic=1989.msg25600#msg25600
-
or traditionally ..
;; // MarkCatch.LSP
;; based on New Rider Articles { I think }
;;;-----------------------------------------------------------------------------------
;;;-----------------------------------------------------------------------------------
;;; KB:mark
;;;* Mark data base to allow KB:catch.
;;;*
(DEFUN kb:mark (/ val)
(SETQ val (GETVAR "cmdecho"))
(SETVAR "cmdecho" 0)
(IF (SETQ *KG:mark (ENTLAST))
nil
(PROGN (ENTMAKE '((0 . "POINT") (10 0.0 0.0 0.0)))
(SETQ *KG:mark (ENTLAST))
(ENTDEL *KG:mark)
)
)
(SETVAR "cmdecho" val)
(PRINC)
)
;;;-----------------------------------------------------------------------------------
;;;-----------------------------------------------------------------------------------
;;; KB:catch
;;;* returns selection set of entities since last KB:mark.
;;;*
(DEFUN kb:catch (/ ss tmp)
(IF *KG:mark
(PROGN (SETQ ss (SSADD))
(WHILE (SETQ *KG:mark (ENTNEXT *KG:mark)) (SSADD *KG:mark ss))
(COMMAND "._select" ss "")
(SETQ tmp ss)
)
(ALERT "*KG:mark not set. \n Run KB:mark before KB:catch.")
)
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------
(DEFUN C:testit ()
(kb:mark)
(PROMPT "\n Select stuff to Copy ")
(SETQ ss (SSGET))
(INITGET 32)
(COMMAND "_copy" ss "" "\\" "\\")
(SETQ ss1 (kb:catch))
)
-
The method outlined above will allow the collection across multiple commands including exploding blocks etc ...
-
The method outlined above will allow the collection across multiple commands including exploding blocks etc ...
Thanks Kerry,
that is great. That exploding block thing is indeed something Very usefull and more than I asked for :lol:
Thanks again, everybody
Bernd
-
Crank,
thanks, your solution is doing the same, but you with the last entry at the moment of the copy instead of a benchmark. works great, too, with less code. :-)
Thanks
Bernd
-
Hi,
You can use a reactor
;;;=================================================================
;;;
;;; JSD.LSP V2.00
;;;
;;; Jeu de Sélection de ce qui a été créé
;;;
;;; Copyright (C) Patrick_35
;;;
;;;=================================================================
(defun commencer_jeu__selection(Rea Cde)
(if (member (car Cde) '("COPY" "MIRROR" "GRIP_MIRROR" "ARRAY"))
(setq $ (ssadd))
)
)
(defun ajouter_jeu_de_selection (Rea Obj)
(if (not (eq (cdr (assoc 0 (entget (cadr Obj)))) "ATTRIB"))
(ssadd (cadr Obj) $)
)
)
(defun enlever_jeu_de_selection (Rea Obj)
(ssdel (cadr Obj) $)
)
(defun faire_jeu_de_selection()
(setq mrea_jsd (vlr-command-reactor nil (list (cons :vlr-commandWillStart (function commencer_jeu__selection))
)
)
mrea_fin (vlr-acdb-reactor nil (list (cons :vlr-objectAppended (function ajouter_jeu_de_selection))
(cons :vlr-objectUnErased (function ajouter_jeu_de_selection))
(cons :vlr-objectErased (function enlever_jeu_de_selection))
)
)
)
(princ "\nSelection of what is created ready, use !$ at the command line.")
(princ)
)
(vl-load-com)
(if (not mrea_jsd)
(faire_jeu_de_selection)
)
(princ)
But I have a problem. :-(
When I do for example a copy of objects of which there are blocks with attributes, a (sslength $) gives me well what was copied.
I make a undo and it's always good.
Now, if I do a MREDO, I have the surprise to discover that the result of (sslength $) corresponds to the number of objects which had been copied more the number of attributes. :-o
I seek in vain from where the error can come and I do not find :?
@+
-
Why would anyone want to add a command reactor for something like this .. just MORE bottleneck potential ..
-
Because you can use it at the command line. for example, If you want to select a past from an another drawing, it's more easy whith this.
You have an additional option of selection at the command line.
@+
-
I like the idea but I'm with Kerry on the potential time penalty you may have to pay.
My system is feeling too slow as it is.
Still wishing for a new computer, ah maybe my Birthday. :oops: