Jump to content

Recommended Posts

Posted

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

 

:unsure:

Posted

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

Posted

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

Posted
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

Posted

Thnx mate, its working perfectly now.. and thanx for the additional info too.

 

.... Regards,

 

Subho

India

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