Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selection Set modify

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
793 Views, 8 Replies

Selection Set modify

Hi,

 

I need the same funcionality as in code below, but without using "command".

The main idea is alowed user to modify Existing Selection Set.

 

(defun gt:ss->lst
  (a:ss /
    i lst
  ) ;_ /
  (setq i 0)
  (if a:ss
    (progn
      (repeat (sslength a:ss)
        (setq
          lst (cons (ssname a:ss i) lst)
          i (1+ i)
        ) ;_ setq
      ) ;_ repeat
      (reverse lst)
    ) ;_ progn
  ) ;_ if
) ;_ defun gt:ss->lst

(defun gt:ss_modify
  (a:en-lst /
  ) ;_ /
  ;;create Selection set
  (setq ss2 (ssadd))
  (foreach f:en a:en-lst
    (ssadd f:en ss2)
  ) ;_ foreach

  ;;Run command and fill with initial content
  (command "_select" ss2)

  ;;Alow the user to modify the contents
  (while (/= (getvar "cmdnames") "")
    (command pause)
  ) ;_ while

  ;;get back the list of enames from modified selection set
  (setq ss3 (ssget "_P"))
  (setq ss3-lst (gt:ss->lst ss3))
) ;_ defun gt:ss_modify

(defun tst:gt:ss_modify
  ( /
  ) ;_ /
  (gt:ss_modify (gt:ss->lst (ssget)))
) ;_ defum tst:gt:ss_modify

 

any idea?

 

Thanks in advance

 

Ales Stanek

8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

Hi all,

 

please, I really need remove the command. Could somebody help me with that.

 

 

Thanks

 

Bye

Message 3 of 9
Moshe-A
in reply to: Anonymous

Hi,

 

i do not exectly understand what you are trying to do but

why (ssget) is not sufficient

 

as far as i understand SELECT command and (ssget) can do the same job?!

 

Moshe

 

Message 4 of 9
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... 

please, I really need remove the command. Could somebody help me with that.

....


I looked at that a little.  If by "modify" you mean you want to be able to both add to and remove from a pre-existing selection set, within the same operation, I didn't find a way other than with the Select command, which is why I didn't reply yesterday.  If all you want to be able to do is add to a selection set, then I think that can be done without (command).

Kent Cooper, AIA
Message 5 of 9
Anonymous
in reply to: Kent1Cooper

Hi Kent1Cooper,

Yes you are right. I prepared for user pre existing selection set. User can added or removed some entities and confirmed the select.

But the fact that without command isn't possible that made. make me very sad.

 

Thanks for answer


Aleš Staněk

Message 6 of 9
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

Hi Kent1Cooper,

Yes you are right. I prepared for user pre existing selection set. User can added or removed some entities and confirmed the select.

But the fact that without command isn't possible that made. make me very sad.

....


I wouldn't guarantee that it can't be done without (command) -- I just haven't found a way [yet?].  It might not be too hard if you don't mind doing all add and remove selections as single items, with which a routine could use (ssadd) and (ssdel).  But if you want all the usual selection options like Window/Crossing, Fence, Multiple, etc., I think that would be more difficult.

Kent Cooper, AIA
Message 7 of 9
Anonymous
in reply to: Kent1Cooper

Hi Kent1Cooper

 

you are right again, I plan alow to user used select mode like crosing and etc. 🙂

 

 

Best Regards

 

 

Aleš

Message 8 of 9
phanaem
in reply to: Anonymous

This is an atempt to imitate "Select" command, including prompts.

I rewrote gs:ss-modify routine (btw, gs: seems to me as a signature. If it is someone else's work, you should include info about the original coder. If it is yours, my appologise)

;rewriten by Stefan M., 07.IX.2012
(defun gt:ss_modify (a:en-lst / *error* e enter gr_point i lt p1 p2 p3 prev reason sel_mode ss value) (defun *error* (msg) (if msg (princ msg)) (redraw) (foreach x a:en-lst (redraw x 4)) ) (grread T 5) (foreach x a:en-lst (redraw x 3)) (princ "\nSelect objects: ") (while (not enter) (setq gr_point (grread T 5 (if sel_mode 1 2)) reason (car gr_point) value (cadr gr_point) ) (cond (sel_mode (redraw) (cond ((= reason 3) (if (setq ss (ssget sel_mode p1 value)) (progn (setq prev 0 i -1 ) (repeat (sslength ss) (setq i (1+ i) e (ssname ss i) ) (if (member e a:en-lst) (setq prev (1+ prev)) (progn (redraw e 3) (setq a:en-lst (cons e a:en-lst)) ) ) ) (princ (strcat (itoa (1+ i)) " found" (if (> prev 0) (strcat " (" (itoa prev) " duplicate), ") ", " ) (itoa (length a:en-lst)) " total\nSelect objects: " ) ) ) (princ "0 found\nSelect objects: ") ) (setq sel_mode nil) ) ((= reason 5) (if (minusp (- (car value) (car p1))) (setq sel_mode "C" lt 1) (setq sel_mode "W" lt 0) ) (grdraw p1 (setq p2 (list (car value) (cadr p1))) 7 lt) (grdraw p2 value 7 lt) (grdraw value (setq p3 (list (car p1) (cadr value))) 7 lt) (grdraw p3 p1 7 lt) ) ) ) ((or (member value '(13 32)) (member reason '(11 12 25))) (setq enter t)) ((= reason 3) (if (setq e (nentselp value)) (progn (setq e (car (if (= (length e) 2) e (last e)))) (princ "1 found") (if (member e a:en-lst) (princ " (1 duplicate)") (progn (setq a:en-lst (cons e a:en-lst)) (redraw e 3) ) ) (princ (strcat ", " (itoa (length a:en-lst)) " total\nSelect objects: ")) ) (progn (princ "Specify opposite corner: ") (setq sel_mode "W" p1 value ) ) ) ) ) ) (*error* nil) a:en-lst )

 

 

Message 9 of 9
Anonymous
in reply to: phanaem

Hi phaneam,

 

thanks for respons, I going to test it today. The code is main. And the signiture insn't GS: but GT: and means "GLOBAL TOOLS" Smiley Happy

 

 

Aleš Staněk

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost