Author Topic: Getting ss from last copy command  (Read 4444 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
Getting ss from last copy command
« 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:

Code: [Select]
(command "copy" en "" pt ptn)
(setq en1 (entlast))

How can I get ss1 when i copy ss?

Thanks in Advance

Bernd

Crank

  • Water Moccasin
  • Posts: 1503
Re: Getting ss from last copy command
« Reply #1 on: April 04, 2007, 09:02:55 PM »
If you look for the last entity in the database before the copy command, you can find all new created entities with entnext.

Code: [Select]
(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
)
« Last Edit: April 04, 2007, 09:24:23 PM by Crank »
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting ss from last copy command
« Reply #3 on: April 04, 2007, 09:13:47 PM »
or traditionally ..
Code: [Select]
;; // 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.")
   )
)
;;;------------------------------------------------------------------
;;;------------------------------------------------------------------

Code: [Select]
(DEFUN C:testit ()

   (kb:mark)
   (PROMPT "\n  Select stuff to Copy ")
   (SETQ ss (SSGET))
   (INITGET 32)

   (COMMAND "_copy" ss "" "\\" "\\")
   (SETQ ss1 (kb:catch))

)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting ss from last copy command
« Reply #4 on: April 04, 2007, 09:15:36 PM »

The method outlined above will allow the collection across multiple commands including exploding blocks etc ...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Amsterdammed

  • Guest
Re: Getting ss from last copy command
« Reply #5 on: April 05, 2007, 07:54:47 AM »

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

Amsterdammed

  • Guest
Re: Getting ss from last copy command
« Reply #6 on: April 05, 2007, 07:59:49 AM »
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

Patrick_35

  • Guest
Re: Getting ss from last copy command
« Reply #7 on: April 05, 2007, 12:01:19 PM »
Hi,
You can use a reactor

Code: [Select]
;;;=================================================================
;;;
;;; 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  :?

@+

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Getting ss from last copy command
« Reply #8 on: April 05, 2007, 09:37:20 PM »
Why would anyone want to add a command reactor for something like this .. just MORE bottleneck potential ..

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Patrick_35

  • Guest
Re: Getting ss from last copy command
« Reply #9 on: April 06, 2007, 02:08:30 AM »
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.

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Getting ss from last copy command
« Reply #10 on: April 06, 2007, 06:53:46 AM »
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:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.