nila_joy Posted March 16, 2012 Posted March 16, 2012 HI.. In my program I have a user input option for selecting a line, but if accidently or mistakenly I clicked in blank window, the program is getting hanged.. Please help me so that if accidently I clicked in blank window, it'll ask me to select a line .. (defun beam_1 (/) (setq beam1_en (entsel "\nPlease Select the CL of Beam 1 :- ")) (setq beam1_data (entget (car beam1_en))) (if (= (cdr (assoc '0 beam1_data)) "LINE") (setq indicator3 7) (progn (setq beam1_data nil) (alert "Entity Selected is not a Line !") (setq indicator3 0) ) ;; progn ) ;; if ) ;; defun Thanks.. Subho India Quote
MSasu Posted March 16, 2012 Posted March 16, 2012 The simplest solution: (defun c:b1(); beam_1 (/) (if [color=red](and [/color](setq beam1_en (entsel "\nPlease Select the CL of Beam 1 :- ")) (setq beam1_data (entget (car beam1_en))[color=black])[/color] (= (cdr (assoc '0 beam1_data)) "LINE")[color=red])[/color] (setq indicator3 7) (progn (setq beam1_data nil) (alert "Entity Selected is not a Line !") (setq indicator3 0) ) ;; progn ) ;; if ) ;; defun Regards, Mircea Quote
jammie Posted March 16, 2012 Posted March 16, 2012 Just to furrther @msasu's post As you have probably noticed, if you fail to pick an object with entsel, the return value is nil. The problem is when you pass the value of beam1_e , which is nil, into entget, it can't processs the nil value, it will instead retun an error. Enget must be passed a valid ename to work correctly Regards Jammie Quote
fixo Posted March 16, 2012 Posted March 16, 2012 Just to furrther @msasu's post As you have probably noticed, if you fail to pick an object with entsel, the return value is nil. The problem is when you pass the value of beam1_e , which is nil, into entget, it can't processs the nil value, it will instead retun an error. Enget must be passed a valid ename to work correctly Regards Jammie Agreed absolutely always need to check first on entsel but not on (car(entsel)) etc Regards Oleg Quote
nila_joy Posted March 18, 2012 Author Posted March 18, 2012 Thnx mate, its working perfectly now.. and thanx for the additional info too. .... Regards, Subho India Quote
Recommended Posts
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.