Deby Ferdian 发表于 2022-7-5 17:55:33

Create Last Select & Previous

How to make a simply code and functional with well of the "Select Last and Previous" onto LISP ?
 
I'd tried with two ways advance. That are; I have try with "ActionRecord" to create it but the result it wasn't prefectly or effectively and I was try this methode by a few time repeatly just to looking for a good result but I didn't or get a nothing. The second way what I've tried is I put my code maded by someone I don't remember where I got this from and gave me get a nothing too. Here it is of the code I got from that a somewhere:
 
 

(defun C:Q1 (); create a Selection Set in the SS/PP "system" (setq _ssinc_ (if _ssinc_ (1+ _ssinc_) 1)) (set (read (strcat "_ss" (itoa _ssinc_) "_")) (ssget)) (prompt (strcat "\nSelection set " (itoa _ssinc_) ".")) (princ)); defun(defun C:Q2 (); select/highlight/grip the latest SS-made set (if _ssinc_   (progn ; then   (setq _ppinc_ _ssinc_)   (sssetfirst nil (eval (read (strcat "_ss" (itoa _ppinc_) "_"))))   (prompt (strcat "\nSelection set " (itoa _ppinc_) "."))   ); progn   (alert "Requires selection sets made with SS."); else ); if (princ)); defun(defun C:Q3 () ; select/highlight/grip the SS-made set Prior to the one most ; recently called for [= PP if used without using PP first] (if _ssinc_   (progn ; then   (setq _ppinc_ (if _ppinc_ (1- _ppinc_) _ssinc_))   (if (eval (read (strcat "_ss" (itoa _ppinc_) "_")))       (sssetfirst nil (eval (read (strcat "_ss" (itoa _ppinc_) "_")))); then       (progn ; else         (alert "No prior selection set available.")         (setq _ppinc_ (1+ _ppinc_))         (sssetfirst nil (eval (read (strcat "_ss" (itoa _ppinc_) "_"))))       ); progn   ); if   (prompt (strcat "\nSelection set " (itoa _ppinc_) "."))   ); progn   (alert "Requires selection sets made with SS."); else ); if (princ)); defun(defun C:Q4 () ; select/highlight/grip the Next SS-made set after the one most ; recently called for [= PP if used without using PP first] (if _ssinc_   (progn ; then   (setq _ppinc_ (if _ppinc_ (1+ _ppinc_) _ssinc_))   (if (eval (read (strcat "_ss" (itoa _ppinc_) "_")))       (sssetfirst nil (eval (read (strcat "_ss" (itoa _ppinc_) "_")))); then       (progn ; else         (alert "No further selection set available.")         (setq _ppinc_ (1- _ppinc_))         (sssetfirst nil (eval (read (strcat "_ss" (itoa _ppinc_) "_"))))       ); progn   ); if   (prompt (strcat "\nSelection set " (itoa _ppinc_) "."))   ); progn   (alert "Requires selection sets made with SS."); else ); if (princ)); defun
 
 
That code gave a function of a "last or forward or backward" of the history of my selection I've compromise before with "Q1" before I can get use them or those feature "last, next and previous my selection".

tombu 发表于 2022-7-5 18:00:02

Not sure what you're trying to do, take a look at: http://forums.augi.com/showthread.php?81175-select-result-lisp-modification#5
The selresult.lsp by Irné Barnard allows you to select objects created by previous commands.It comes in handy more often than you might think.

Deby Ferdian 发表于 2022-7-5 18:04:32

It seems doesn't work for me. why ? where from my fault is ?
 
Itry with type "Result" at the command line but seems nothing happen.anything! and I was add new command too into my "CUI" as a suggested by @irneb but it still doesn't work for me. I loaded the "SelResult" from "APPLOAD". Where does this problem come from?
 
I don't understand. if you mind whould you explain this to me @tombu everything of the steps of them step by step. Hopeless! pleasssssse..   ^_^"
 
 
 
 
~.Thanks again and sorry about my words. I am still beginner and I am still also process of learning in english.~

Deby Ferdian 发表于 2022-7-5 18:08:48

Somebody help.. !

David Bethel 发表于 2022-7-5 18:13:16

UnTested
 

(defun c:test (/ s1 s2 s3 i e) (setq s1 (ssget "P")) (setq s2 (ssget "L")) (setq s3 (ssadd)) (and s1      (setq i 0)      (while (setq e (ssname s1 i))             (ssadd e s3)             (setq i (1+ i)))) (and s2      (setq i 0)      (while (setq e (ssname s2 i))             (ssadd e s3)             (setq i (1+ i))))(prin1))

marko_ribar 发表于 2022-7-5 18:17:03

Yes David, I see what you're getting on, but I think OP wanted to select not last entity and previous selection set, but previous selection and new one and make single s3 from them...
 

(defun c:test (/ s1 s2 s3 i e) (setq s1 (ssget "_P")) (setq s2 (ssget "_:L")) ;;; user is prompted to select objects on unlocked layer(s)... (setq s3 (ssadd)) (and s1      (setq i 0)      (while (setq e (ssname s1 i))             (ssadd e s3)             (setq i (1+ i)))) (and s2      (setq i 0)      (while (setq e (ssname s2 i))             (ssadd e s3)             (setq i (1+ i)))) (sssetfirst nil s3)(prin1))

David Bethel 发表于 2022-7-5 18:19:40

Could be.Maybe we'll find out

tombu 发表于 2022-7-5 18:27:26

First it's meant to be called transparently so you need to type "'Result" at the command line when prompted for a selection as shown in the link.
 
Second to keep track of command results it must be loaded before those commands are run.I load the routine in acaddoc.lsp as I don't have much faith in "APPLOAD".
 
Marko Ribar's lisp does combine previous and last selections as you asked.Keep in mind last is the last single object added to the drawing.If you select three objects and copy them the last selection will only include the last of the three objects selected while 'Result would select all three.If none of these solutions is exactly what you're looking for can you explain a situation when you would use this?

Deby Ferdian 发表于 2022-7-5 18:29:51

Sorry still not solve I was load the "selresult.lsp" in acaddoc.lsp as "S::STARTUP" but it still doesn't want work. The cad system in command line said "no result set available" my effort in vain, to no avail. Please help need enlightenment soon! Thx, my appreciate and I was very fortunate if would anyone want to help me be finish!
 
 
 
~.Thanks again and sorry about my words. I am still beginner and I am still also process of learning in english.~

tombu 发表于 2022-7-5 18:34:31

I assume "no result set available" means you had not previously added any objects in the current drawing session. 
As an example I used the line command to draw 4 line segments then selected them and copied them.Afterwards I started the move command and used 'Result which offered me the option to enter 0 for the output of the Copy command or 1 for the output of the Line command.I entered 0 and entered again to finish selecting objects then picked the from and to points.
 
Copy from text screen of commands:
Command: _line
Specify first point:
Specify next point or :
Specify next point or :
Specify next point or :
Specify next point or :
Specify next point or :
 
Command: Specify opposite corner or :
Command:
Command:
Command: _copy 4 found
 
Current settings:Copy mode = Multiple
Specify base point or :
Specify second point or :
Specify second point or :
 
Command: M
MOVE
Select objects: 'Result
Which one of these do you want to select? 0-COPY 1-LINE : 0
4 found
 
Select objects:
 
Select objects:
 
Specify base point or :
Specify second point or :
 
If you're still having trouble paste from your text screen where you've drawn something then were unable to select it with 'Result after starting a command that prompts for a selection like Move or Copy.
页: [1] 2
查看完整版本: Create Last Select & Previous