Jump to content

How to add options to ssget?


Ahankhah

Recommended Posts

Hi friends,

is it possible to add behaviors defined by (initget) function to (ssget) :?:

(As most of you know, it is possible for other input functions such as (entsel), (entselp), (getpoint), ...)

 

An example is like this:

Command: mycommand

Select objects, or [by Style/by Layer/by Color/...]: s

Select text object to get its style:

.

.

.

 

I appreciate any help :)

Link to comment
Share on other sites

You cannot use the initget function with ssget.

 

Only the following functions can be used with initget:

 

getint, getreal, getdist, getangle, getorient, getpoint, getcorner, getkword, entsel, nentsel, nentselp.

Link to comment
Share on other sites

Try something like this:

 

(defun c:test (/ Prcd gr Npt Mode Par )
     (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:")
    (while (null Prcd)
      (setq gr (grread nil 4 2) Mode (car gr))
       (cond
          ((= 3 Mode)
         (princ "\nSelect Mode")
         (setq Objects (ssget "_C" (cadr gr)
              (setq Npt (Getcorner (cadr gr) "\nOther Corner:"))))
         (foreach mp (vl-remove-if 'listp
                       (mapcar 'cadr(ssnamex Objects)))
          (redraw mp 3))
         (setq Prcd T))
       ((and (= 2 Mode)
             (setq Par (member (cAdr gr) '(67 76 83 99 108 115))))
          (princ (strcat "\nYou Pressed " (chr (car Par))))
         (setq Prcd T))
     )
      )
     (princ)
     )

 

I leave the rest to your imagination ;)

 

HTH

Edited by pBe
Replace sssetfirst with redraw
Link to comment
Share on other sites

Also try this. :)

 


(defun C:TEST ()
   (setq SEL (ssadd))
   (initget "S L C")
   (setq a (entsel "\nSelect objects, or by [style/Layer/Color]...:"))
   (if (= a "S")
       (progn
           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "L")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )
   (if (= a "S")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )    

   (if (and (/= a nil)(/= a "S")(/= a "L")(/= a "C"))
       (progn
           (setq SEL (ssadd (car a) SEL))
           (command "_select" SEL pause)
           (setq SEL (ssget "_P"))
       )     
   )
   (if (= a nil)
       (progn
           (command "_select" "_BOX" (cadr (grread T)) pause)
           (setq SEL (ssget "_P"))
       )
   )
)

  • Like 1
Link to comment
Share on other sites

You cannot use the initget function with ssget.

 

Only the following functions can be used with initget:

 

getint, getreal, getdist, getangle, getorient, getpoint, getcorner, getkword, entsel, nentsel, nentselp.

 

You are right Lee,

but I am seeking a way to imitate initget for ssget.

Link to comment
Share on other sites

Also try this. :)

 


(defun C:TEST ()
   (setq SEL (ssadd))
   (initget "S L C")
   (setq a (entsel "\nSelect objects, or by [style/Layer/Color]...:"))
   (if (= a "S")
       (progn
           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "L")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )
   (if (= a "S")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )    

   (if (and (/= a nil)(/= a "S")(/= a "L")(/= a "C"))
       (progn
           (setq SEL (ssadd (car a) SEL))
           (command "_select" SEL pause)
           (setq SEL (ssget "_P"))
       )     
   )
   (if (= a nil)
       (progn
           (command "_select" "_BOX" (cadr (grread T)) pause)
           (setq SEL (ssget "_P"))
       )
   )
)

Thank you GP_ for your reply, but has no options like Implied Windowing, etc.

Link to comment
Share on other sites

...but has no options like Implied Windowing, etc.

 

 

You want the egg and the hen. :)

 

 


(defun C:TEST (/ a b option)

   (setq SEL (ssadd))
   (initget "? ST LA CO W L C B ALL F WP CP G A R M P U AU SI SU O")
   (setq a (entsel "\nSelect objects, or by [sTyle/LAyer/COlor]...:  "))
   (if (= a "?")
       (progn
           (setq b nil)
           (while (not (member b (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP"
                     "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))) 
               (prompt "Expects a point or" )
               (prompt "\nWindow/Last/Crossing/BOX/ALL/Fence/WPolygon/")
               (prompt "CPolygon/Group/Add/Remove/Multiple/Previous/")
               (prompt "Undo/AUto/SIngle/SUbobject/Object ")
               (prompt "\nSelect objects:" )
               (setq b (strcase (getstring)))
               (if (= b nil) (exit))
           )
           (setq a b)
       )
   )
   (if (= a "ST")
       (progn
           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "LA")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "CO")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )    

   (if (and
           (/= a nil)
           (not
               (member a
                   (list "?" "ST" "LA" "CO" "W" "L" "C" "B"
                         "BOX" "ALL" "F" "WP" "CP" "G" "A"
                         "R" "M" "P" "U" "AU" "SI" "SU" "O")
               )
           )
       )
       (progn
           (setq SEL (ssadd (car a) SEL))
           (command "_select" SEL pause)
           (setq SEL (ssget "_P"))
       )     
   )

   (if (= a nil)
       (progn
           (command "_select" "_BOX" (cadr (grread T)) pause)
           (setq SEL (ssget "_P"))
       )
   )
   (if (member a (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP"
                     "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))
       (progn
           (setq option (strcat "_" a))
           (command "_select" option pause)
           (setq SEL (ssget "_P"))
       )     
   )

)

Link to comment
Share on other sites

Attached is an old program of mine, an attempt to create a UCS-Aligned ssget function, it could be modified to add extra options.

 

Lee

 

It is fine Lee. Your brain is a treasure, thank you very much :D

Link to comment
Share on other sites

You want the egg and the hen. :)

 

 


(defun C:TEST (/ a b option)

   (setq SEL (ssadd))
   (initget "? ST LA CO W L C B ALL F WP CP G A R M P U AU SI SU O")
   (setq a (entsel "\nSelect objects, or by [sTyle/LAyer/COlor]...:  "))
   (if (= a "?")
       (progn
           (setq b nil)
           (while (not (member b (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP"
                     "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))) 
               (prompt "Expects a point or" )
               (prompt "\nWindow/Last/Crossing/BOX/ALL/Fence/WPolygon/")
               (prompt "CPolygon/Group/Add/Remove/Multiple/Previous/")
               (prompt "Undo/AUto/SIngle/SUbobject/Object ")
               (prompt "\nSelect objects:" )
               (setq b (strcase (getstring)))
               (if (= b nil) (exit))
           )
           (setq a b)
       )
   )
   (if (= a "ST")
       (progn
           ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "LA")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )

   (if (= a "CO")
       (progn
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
       )
   )    

   (if (and
           (/= a nil)
           (not
               (member a
                   (list "?" "ST" "LA" "CO" "W" "L" "C" "B"
                         "BOX" "ALL" "F" "WP" "CP" "G" "A"
                         "R" "M" "P" "U" "AU" "SI" "SU" "O")
               )
           )
       )
       (progn
           (setq SEL (ssadd (car a) SEL))
           (command "_select" SEL pause)
           (setq SEL (ssget "_P"))
       )     
   )

   (if (= a nil)
       (progn
           (command "_select" "_BOX" (cadr (grread T)) pause)
           (setq SEL (ssget "_P"))
       )
   )
   (if (member a (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP"
                     "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))
       (progn
           (setq option (strcat "_" a))
           (command "_select" option pause)
           (setq SEL (ssget "_P"))
       )     
   )

)

GP_, thank you very much. Your code is a great help :D

Link to comment
Share on other sites

This is as close as i can get with implied selections

 

(defun c:test (/ Prcd gr Npt Mode Par )
     (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:")
    (while (null Prcd)
      (setq gr (grread nil 4 2) Mode (car gr))
       (cond
          ((= 3 Mode)
         (princ "\nSelect Mode")
         (initget 32)
         (setq Npt (Getcorner (cadr gr) "\nOther Corner:"))
         
         (setq Objects (ssget (if (< (car (cadr gr))(car Npt)) "_W" "_C") (cadr gr) npt
              ))
         (foreach mp (vl-remove-if 'listp
                       (mapcar 'cadr(ssnamex Objects)))
          (redraw mp 3))
         (setq Prcd T))
       ((and (= 2 Mode)
             (setq Par (member (cAdr gr) '(67 76 83 99 108 115))))
          (princ (strcat "\nYou Pressed " (chr (car Par))))
         (setq Prcd T))
     )
      )
     (princ)
     )

 

Hope this helps

Link to comment
Share on other sites

This is as close as i can get with implied selections

 

(defun c:test (/ Prcd gr Npt Mode Par )
     (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:")
    (while (null Prcd)
      (setq gr (grread nil 4 2) Mode (car gr))
       (cond
          ((= 3 Mode)
         (princ "\nSelect Mode")
         (initget 32)
         (setq Npt (Getcorner (cadr gr) "\nOther Corner:"))
         
         (setq Objects (ssget (if (< (car (cadr gr))(car Npt)) "_W" "_C") (cadr gr) npt
              ))
         (foreach mp (vl-remove-if 'listp
                       (mapcar 'cadr(ssnamex Objects)))
          (redraw mp 3))
         (setq Prcd T))
       ((and (= 2 Mode)
             (setq Par (member (cAdr gr) '(67 76 83 99 108 115))))
          (princ (strcat "\nYou Pressed " (chr (car Par))))
         (setq Prcd T))
     )
      )
     (princ)
     )

 

Hope this helps

pBe, your great help :o is appreciated. :D

 

Thank you very much. :)

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