Ahankhah Posted February 28, 2011 Posted February 28, 2011 Hello friends, as some of you know, entsel is a good function to select single objects, but it has a severe flaw in distinguishing between "pressing enter" and "selecting nothing":(. Has Anyone a suggestion to conquer this defection:oops:? Quote
BlackBox Posted February 28, 2011 Posted February 28, 2011 I'm not sure I understand your question... What behavior are you trying to invoke? Quote
Ahankhah Posted February 28, 2011 Author Posted February 28, 2011 Here is the code: (defun C:Length () (MT-TotalLength)) (defun MT-TotalLength (/ *error* ans layname cont len) (MT-Start) (initget "Name eXit _Name eXit") (setq ans nil) (setq ans (entsel "\nSelect an object on the layer to proceed [Name/eXit] <eXit>: " ) ) (cond ((member ans '(nil "eXit")) (exit)) ((= "Name" ans) (setq cont T) (while cont (setq layname (getstring T "\nEnter layer name: ")) (if (null (read layname)) (progn (princ "\nNull name for layer not allowed, try again.")) (progn (if (tblsearch "layer" layname) (setq cont nil) (princ (strcat "\nLayer \"" layname "\" not exists, try again." ) ) ) ) ) ) ) (T (setq layname (cdr (assoc 8 (entget (car ans)))))) ) (and (setq ss (ssget "_X" (list (cons -4 "<OR") (cons 0 "LINE") (cons 0 "ARC") (cons 0 "LWPOLYLINE") (cons -4 "OR>") (cons 8 layname) ) ) ) (setq len (MT-Calc-Length ss)) ) (setq msg (strcat "Total length of objects (Lines, Arcs, Polylines) in layer: \"" layname "\"\n\nequals to: " (rtos len) ) ) (princ msg) (alert msg) (MT-End) ) (defun MT-Calc-Length (ss / sslist len) (setq sslist (MT-Conv-SS-To-List ss)) (setq len 0) (foreach obj sslist (setq len (+ len (MT-Get-Obj-Length obj)))) ) (defun MT-Conv-SS-To-List (ss / entlist index) (setq entlist nil) (if (= 'PICKSET (type ss)) (progn (setq index -1) (repeat (sslength ss) (setq entlist (append (list (ssname ss (setq index (1+ index)))) entlist ) ) ) ) ) (reverse entlist) ) (defun MT-Error (msg) (or (member (read msg) '(nil *BREAK *CANCEL*)); *EXIT* isn't an error condition (princ (strcat "\n** Error: " msg " **")) ) (setvar 'Cmdecho 1) (princ) ) (defun MT-Start () (setq *error* MT-Error) (setvar 'Cmdecho 0)) (defun MT-End () (MT-Error "")) (defun MT-Exit () (exit)) As you can check, there is no difference between pressing Enter and clicking mouse botton in an empty area in work space. This is the above mentioned restriction. Quote
Lee Mac Posted February 28, 2011 Posted February 28, 2011 As Alan states - can can use the ERRNO System Variable... See here for an example. Quote
Ahankhah Posted March 1, 2011 Author Posted March 1, 2011 alanjt & Lee Mac, thank you very much. I will use the instruction and the mentioned code. 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.