Code Red > AutoLISP (Vanilla / Visual)
select previous group via lisp problem...
(1/1)
danglar:
Hi folks.
This lisp ( attached one) can draw spline ,Select Objects Within/Crossing it and erase spline used for selection.
In this case I need to reselect previoustly selected entities within spline and than I created group from these objects..
But now I need to select previous group.. It's possible if I use GROUP command from command line, but problematical for me to do it via lisp
Do you have any idea how to do it?
I appreciate your quick response and the time you spent in helping me out. Thanks
ronjonp:
Maybe this will help:
--- Code - Auto/Visual Lisp: ---(defun c:swc (/ _addgroup _pac add e i ss temp) ;; Select Objects Within/Crossing Curve ;; Alan J. Thompson, 03.31.11 ;; Slightly modified by Igal Averbuh 2017 (added option for splines) ;; RJP simplified & added groups 02.22.2017 (vl-load-com) (defun _pac (e / l v d lst) (setq d (- (setq v (/ (setq l (vlax-curve-getdistatparam e (vlax-curve-getendparam e))) 500.)))) (while (< (setq d (+ d v)) l) (setq lst (cons (vlax-curve-getpointatdist e d) lst))) ) (defun _addgroup (listofobjects / grp grps name) ;; Check that all items in the list are vla-objects (if (and (vl-every '(lambda (x) (eq (type x) 'vla-object)) listofobjects) (setq grps (vla-get-groups (vla-get-activedocument (vlax-get-acad-object)))) ) (progn (setq grp (vla-add grps "*")) (vlax-invoke grp 'appenditems listofobjects) listofobjects ) ) ) (initget 0 "Crossing Within") (setq *swc:opt* (cond ((getkword (strcat "\nSpecify selection method witin curve [Crossing/Within] <" (cond (*swc:opt*) ((setq *swc:opt* "Crossing")) ) ">: " ) ) ) (*swc:opt*) ) ) (princ "\nSelect closed curves to select object(s) within: ") (if (setq add (ssadd) ss (ssget ":L" '((0 . "SPLINE"))) ) (progn (repeat (setq i (sslength ss)) ;; Must be visible on screen for point selection to work (if (setq temp (ssget (if (eq *swc:opt* "Crossing") "_CP" "_WP" ) (_pac (setq e (ssname ss (setq i (1- i))))) ) ) (progn ;; Remove boundary from selection so it won't get grouped (ssdel e temp) ;; Delete boundary (entdel e) ;; Group objects (_addgroup (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex temp)))) ) ;; Highlight selection ;; (sssetfirst nil temp) ) ) ) ) ) (princ))
danglar:
Thank you ronjonp for your significant approach
I did a little modification of this code: (see attached one)
1. code added to main routine
2. your code was slightly modified - now spline erased automatically
3. highlighting of selected objects was turned ON
Thank you again for cooperation
ronjonp:
--- Quote from: danglar on February 23, 2017, 02:44:04 AM ---Thank you ronjonp for your significant approach
I did a little modification of this code: (see attached one)
1. code added to main routine
2. your code was slightly modified - now spline erased automatically
3. highlighting of selected objects was turned ON
Thank you again for cooperation
--- End quote ---
Glad it worked for you.
Navigation
[0] Message Index
Go to full version