Jump to content

A wrapper for ssget function


samifox

Recommended Posts

;; ssget - Lee Mac

;; A wrapper for the ssget function to permit the use of a custom selection prompt

;; msg - [str] selection prompt

;; arg - [lst] list of ssget arguments

 

(defun LM:ssget ( msg arg / sel )
   (princ msg)
   (setvar 'nomutt 1)
   (setq sel (vl-catch-all-apply 'ssget arg))
   (setvar 'nomutt 0)
   (if (not (vl-catch-all-error-p sel)) sel)
)

 

 

why ssget needs a wrapper?

Link to comment
Share on other sites

why ssget needs a wrapper?

 

This 'wrapper' allows you to quickly provide a custom Selection Filter, and user prompt, without duplicating the code in each-and-ever-single routine; the wrapper is merely a sub-function.

 

Cheers

 

 

 

[Edit] - Quick examples:

 

(defun c:SelectCircles (/ ss)
 (if (setq ss (LM:ssget "\nSelect circles: " '(((0 . "CIRCLE")))))
   (prompt
     (strcat
       "\nYou selected "
       (itoa (setq ss (sslength ss)))
       " circle"
       (if (= 1 ss)
         ""
         "s "
       )
     )
   )
 )
 (prompt "\nNothing selected ")
 (princ)
)

(defun c:SelectLines (/ ss)
 (if (setq ss (LM:ssget "\nSelect lines: " '(((0 . "LINE")))))
   (prompt
     (strcat
       "\nYou selected "
       (itoa (setq ss (sslength ss)))
       " line"
       (if (= 1 ss)
         ""
         "s "
       )
     )
   )
 )
 (prompt "\nNothing selected ")
 (princ)
)

Link to comment
Share on other sites

i see...

 

1.trying to learn how nomutt effect the prompt...but cant really stage a senario when its actually makes a different.

2.what this code is actually saying in plain english?

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...