Help with Nil and not found message

Help with Nil and not found message

kthmarks
Contributor Contributor
454 Views
5 Replies
Message 1 of 6

Help with Nil and not found message

kthmarks
Contributor
Contributor

I have tried to figure this out but I continue to either get errors or, when I do get success I get the "no objects found" message even when there is one.  I am obviously a noob but can't wrap my head around the If statement or if I even need it with the sssetfirst command.

 

I'm sure I am over complicating this.

 

SMH

 

(defun C:GET_N (/ echo ssN)
(setvar "Expert" 3)
(setq echo (getvar 'cmdecho))
(setvar 'cmdecho 1)
;;(sssetfirst nil ssN)
(prompt
(if setq ssN (ssget "_x" '((8 . "*NEW*"))))
;;(command "select" ""))
(print "No objects found"))
(princ)
)

 

 

0 Likes
Accepted solutions (1)
455 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this? 

...to select all objects in *new* layer at current space. Limit to current space is there because we're unable to select/highlight them anyway.

 

(defun C:GET_N (/ ssN)

(if (setq ssN (ssget "_x" (list '(8 . "*NEW*") (cons 410 (getvar 'ctab)))))
  (sssetfirst nil ssN)
  (print "\nNo objects found"))

  
(princ)
)

 

0 Likes
Message 3 of 6

kthmarks
Contributor
Contributor

Perfect thank you @ВeekeeCZ .  I'm ashamed to admit how long it took me to ask for help.  I really appreciate it.

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

You'll learn nothing if you ask for help right away. So...

Message 5 of 6

Moshe-A
Mentor
Mentor

@kthmarks  hi,

 

check this  😀

 

(defun C:GET_N (/ ssN)
 (setvar "cmdecho" 0)
 (setvar "expert" 3)
  
 (if (setq ssN (ssget "_x" '((8 . "*NEW*"))))
  (sssetfirst nil ssN)
  (prompt "No objects found")
 )

 (setvar "expert" 0)
 (setvar "cmdecho" 1)
  
 (princ)
)

 

 

 

0 Likes
Message 6 of 6

ВeekeeCZ
Consultant
Consultant

@Moshe-A that's not fun. Those sysvars have no effect on the process. Just messing with his head. Besides, it's not good example on how to correctly reset them.