ssHistory - access to selection sets created by previous commands

this small Programm gives you access to the selection sets which have been consecutively added to the drawing by the last five commands.

Enter command SSHISTORY and the number of the command (1 is the last, 2 thecommand before the last, 3 the command before that and so on), and the elements, that have been added by that command will be highlighted and pickselected.

You can change the number of commands that can bee accessed back in history by changing the variable SSH:MAXHISTORY to another value, i.e. (setq ssh:maxhistory 10) for storing the elements from the last 10 commands.

 

(defun sshistory-create-editor-reactor ()
(setq SSH:REACTOR
(VLR-Editor-Reactor
nil
'(
(:vlr-commandwillstart . sshistory-startfunction)
(:vlr-commandended . sshistory-endfunction)
)
)
)
)


(defun sshistory-startfunction (reactor cmdlist)
(setq SSH:ENTLAST (entlast))
)


(defun sshistory-endfunction (reactor cmdlist)
(if (<= SSH:MAXHISTORY (length SSH:HISTORY))
(setq SSH:HISTORY (reverse (cdr (reverse SSH:HISTORY))))
)
(setq SSH:HISTORY (cons (sshistory-findnewset SSH:ENTLAST) SSH:HISTORY))
)


(defun sshistory-select-nth (n)
(nth (1- n) SSH:HISTORY)
)


(defun sshistory-findnewset (en / nset)
(setq nset (ssadd))
(if en
(while (setq en (entnext en))
(if (member (cdr (assoc 0 (entget en))) '("VERTEX" "SEQEND"))
nil
(setq nset (ssadd en nset))
)
)
(setq nset (ssget "X"))
)
nset
)


(defun c:sshistory ()
(initget)
(if (setq n
(getint
"\nget the newly created sset of the command N times before <1>: "
)
)
(if (< n (length SSH:HISTORY))
(sssetfirst (nth (1- n) SSH:HISTORY) (nth (1- n) SSH:HISTORY))
(princ
(strcat "\nssHistory error: ssHistory only available for "
(itoa (length SSH:HISTORY))
" commands"
)
)
)
(sssetfirst (car SSH:HISTORY)(car SSH:HISTORY))
)
(prin1)
)


(if (not SSH:REACTOR) (sshistory-create-editor-reactor))

(setq SSH:MAXHISTORY 5)

(princ "\nssHistory gives you access to the selection sets")
(princ "\nthat have been added to the drawing by the last")
(princ "\n5 commands.")
(princ "\nssHistory may behave faulty when commands are")
(princ "\nused which may have deleted the last entity in")
(princ "\nthe drawing base (i.e. delete, block etc).")
(princ "(c) Tom Berger, berger@archtools.de")
(prin1)