Jump to content

select previous group via lisp problem...


danglar

Recommended Posts

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 do it?

 

I appreciate your quick response and the time you spent in helping me out. Thanks

Lasso Selection Test - LAS.lsp

Link to comment
Share on other sites

Hi there.

 

Sometimes you get more views by directly posting the code (of course between code tags to avoid the wrath of gods and terminators...:shock:) instead of attaching it, forcing users to login to actually see it.

 

So, if I understood correctly, the only thing you are trying to achieve is to erase the spline, and end up with the selection originally made by the lisp. Since in the lisp there was already a var (e) containing the of the spline, it can easilly be achieved by simply adding the line I added in green, deleting the spline just before the selection is made and returned. No need for extra mileage there!

A little side note: It can be irritating to have a lisp routine that once executed change settings without reverting them back at the end. Best practice: look and store its original value in a variable, change the var as needed, then change it back using its original value from the created variable. (See added code in red).

 

;;; Make Lasso Selection (draw spline and Select Objects Within/Crossing it)
;;; Special thanks to Alan J. Thompson


(defun c:SWC (/ _pac add ss i e temp it o a b pts tempC i3 ec)
 ;; Select Objects Within/Crossing Curve
 ;; Alan J. Thompson, 03.31.11
 ;; Slightly modified by Igal Averbuh 2017 (added option for splines)
 ;; Slightly modified by Jef! 2017 (erased spline + osmode restoration)
 (vl-load-com)

 (defun _pac (e / l v d lst)
   (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
   (while (< (setq d (+ d v)) l)
     (setq lst (cons (vlax-curve-getPointAtDist e d) lst))
   )
 )

 (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"
               )
     )
   (progn (repeat (setq i (sslength ss))
            (if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i)))))))
              (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
            )

            (if (eq *SWC:Opt* "Crossing")
              (progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b)
                     (setq pts (mapcar 'vlax-safearray->list (list a b)))
                     (if (setq tempC (ssget "_C"
                                            (list (caar pts) (cadar pts) 0.)
                                            (list (caadr pts) (cadadr pts) 0.)
                                     )
                         )
                       (repeat (setq i3 (sslength tempC))
                         (if (vlax-invoke
                               o
                               'Intersectwith
                               (vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3)))))
                               acExtendNone
                             )
                           (ssadd ec add)
                         )
                       )
                     )
              )
            )
          )
          [b][color=green](vla-delete (vlax-ename->vla-object e))[/color][/b]
          (sssetfirst nil add)
          (ssget "_I")
   )
 )
 (princ)
)

(defun C:LAT ( / [b][color=red]oldosmode[/color][/b] )
 [b][color=red](setq oldosmode (getvar 'osmode))[/color][/b]
 (setvar "osmode" 16384)
 (command "_.spline")
 (while (> (getvar "CmdActive") 0)
   (command pause)
 )
 (c:swc)
 [b][color=red](if oldosmode
     (setvar 'osmode oldosmode)
 )[/color][/b]
 (princ)
)

 

Cheers!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...