Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select objects or <select all>

8 REPLIES 8
Reply
Message 1 of 9
fk
Advocate
639 Views, 8 Replies

Select objects or <select all>

Hi.

I wonder if someone have some code for handling this "Select objects or <select all>:"?

Thanks in advance.

 

\Freddy

8 REPLIES 8
Message 2 of 9
pbejse
in reply to: fk

Two ways you can do that

 

<Not thoroughly tested> 

 

single selection

(defun c:test (/ options objects)
	  (setq options (entsel "\nSelect object or <select all>:"))
	 	(if  (= options nil)
		  	(setq objects (ssget "_X"))
  	)
  (sssetfirst nil objects)(princ)
)

This one for ssget <multiple selection> 

 

(defun c:test (/ options objects)
  	  (prompt "\nSelect objects or <select all>:")	 
	  (setq objects (ssget))
	 	(if  (= objects nil)
		  	(setq objects (ssget "_X"))
  	)
  (sssetfirst nil objects)(princ)
)

 

Message 3 of 9
fk
Advocate
in reply to: fk

Thanks.

It is something like the second suggestion, but that leave me with:

 

Select objects or <select all>:
Select objects:

It had been nice to handle it with only the first line like it is in the TRIM and EXTEND command. Is that possible?

 

\Freddy

Message 4 of 9
pbejse
in reply to: fk

Play around with NOMUTT variable

 

(defun c:test ( / objects)
	(prompt "\nSelect Object or <select all>:)")
  	(setvar "nomutt" 1)
  	(setq objects (ssget))
  	(setvar "nomutt" 0)
  	(if (not objects)
	  	(setq objects (ssget "_X"))
	  	)
	(sssetfirst nil objects)
  )

 

Message 5 of 9
fk
Advocate
in reply to: fk

Thanks a lot. Clever programming. 🙂

 

\Freddy

 

Message 6 of 9
cadking2k5
in reply to: fk

Do you know what function to use to make it so you can select an object and at the same time you have an option like radius and it keeps it in until you change it like the fillet command I know about this if I get this I will have a perfect command something like this but I can not pick an object just a distance and I have on option
 
 
(setq oldlth (getvar "userr1"))
(setq lth (getdist (strcat "\nPick a Length:<" (rtos oldlth) ">:")))
(if(= lth nil)(setq lth oldlth))
(setvar "userr1" lth)
Message 7 of 9
stevor
in reply to: fk

One common way to provide a default answer is implemented in a substiture for the getdist or getreal, like: ; GET_D, with Default value, D. AusCadd.com (Defun Get_D (d s / ans ) (setq d (if (numberp d) d 1.0) ans (getdist (strcat " " s " < " (rtos d 2 4) " > "))) (if ans ans d) ) ; get real (DeFun get_r (d ps / ans ) ( (setq d (if (and d (numberp d)) d 0) ps (if (str_p ps) ps "\n Enter Number: ") ans (getreal (strcat " " ps " < " (rtos d 2 4) " > "))) (if ans ans d)) Do not know how that text insertion into this Reply will go, so an attached is ttried. The text, and others, at Auscadd.com, Free Subroutines. For your application: (setq oldlth (getvar "userr1")) (setq lth (get_d oldlth)) ; mod'd (if(= lth nil)(setq lth oldlth)) (setvar "userr1" lth) Normally, the routine would set the defualt value upon loading, and offer a user change upon each call, or upon loading if the values seldom changed.
S
Message 8 of 9
stevor
in reply to: cadking2k5

Retry a reply, in Rich text mode, IE8, XP:

 

One common way to provide a default answer is implemented in a substiture for the getdist or getreal, like:

 

 ; GET_D,  with Default value, D.   AusCadd.com
 (Defun Get_D (d s / ans ) (setq d (if (numberp d) d 1.0)
      ans (getdist (strcat " " s " &lt; " (rtos d 2 4) " &gt; ")))
   (if ans ans d) )

 

 ; get real
 (DeFun get_r (d ps / ans ) (
  (setq d (if (and d (numberp d)) d 0)
        ps (if (str_p ps) ps "\n Enter Number:  ")
        ans (getreal (strcat " " ps " &lt; " (rtos d  2 4) " &gt; ")))
  (if ans ans d))

 

Do not know how that text insertion into this Reply will go, so an attached is ttried. The text, and others, at Auscadd.com,  Free Subroutines.

 

For your application:
(setq oldlth (getvar "userr1"))
(setq lth (get_d oldlth)) ; mod'd
(if(= lth nil)(setq lth oldlth))
(setvar "userr1" lth)

 

Normally, the routine would set the defualt value upon loading, and offer a user change upon each call, or upon loading if the values seldom changed.


 

S
Message 9 of 9
pbejse
in reply to: cadking2k5

(setq val (cond
	((getdist (strcat "\nEnter distance"
                 (if val (strcat " <" (rtos val) ">: ") ": ")
                            )))(val))
                )

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost