Select first and then run program

Select first and then run program

Anonymous
Not applicable
1,012 Views
3 Replies
Message 1 of 4

Select first and then run program

Anonymous
Not applicable
Hi guys,
I'm trying to make a lisp involving ssget.
Is there a way for user to select the objects before running the lisp and that he would not be ask again to select object by the ssget?
I mean, like in autocad commands you can select and then choose command, or you can choose command and then select.

Thanks
0 Likes
Accepted solutions (1)
1,013 Views
3 Replies
Replies (3)
Message 2 of 4

Satoews
Advocate
Advocate

 

(or setthisvariable
(setq setthisvariable (ssget)))

 

(defun c:trythis () ;; don't put setthisvariable in the parenthesis
  (setq setthisvariable (ssget))
)

 

Shawn T
0 Likes
Message 3 of 4

Kent1Cooper
Consultant
Consultant

Yes.  User something like:

(if (not (setq ss (ssget "_I"))); if there is not an Implied [= pre-] selection [if there is, it will put that into 'ss']

  (setq ss (ssget)); then -- ask the User to select

); if

 

Then go on to do what you want with the 'ss' selection set.  Add whatever filtering you like to either selection -- that is, even a preselection like that can filter for specific characteristics among the pre-selected objects, and only "keep" the qualifying ones.

Kent Cooper, AIA
Message 4 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Anonymous wrote:
Hi guys,
I'm trying to make a lisp involving ssget.
Is there a way for user to select the objects before running the lisp and that he would not be ask again to select object by the ssget?
I mean, like in autocad commands you can select and then choose command, or you can choose command and then select.

Thanks

Use just (ssget) as it is. It works native. Try it. No need for "I" parameter. 

 

 

Edit: Don't get me wronk, ssget's "I" parametr is very useful... it allows you to do one thing if you have some object preselected, the other if not. Asi this example:

 

Spoiler
(defun C:SetByLay ()
 (if (ssget "_I")
   (command "_.setbylayer" "_y" "_y")
   (progn
     (command "_.-color" "BYLAYER"
	      "_.-lweight" "BYLAYER"
	      "_.-linetype" "_s" "BYLAYER" "")
     (if (eq (getvar "pstylemode") 0)
       (command "_.-plotstyle" "_c" "BYLAYER" ""))))
  (princ)
)

 

0 Likes