0 Members and 1 Guest are viewing this topic.
Lee Mac Version 2011 http://www.theswamp.org/index.php?topic=39042.msg442350#msg442350
;; Selection or Text - Lee Mac;; Prompts the user to select an object or enter an arbitrary string.;; msg - [str] [Optional] Prompt string;; ftr - [lst] [Optional] ssget filter list;; Returns: [ent/str] Entity name of selected entity or entered string; "" if enter is pressed.(defun LM:select-or-text ( msg ftr / gr1 gr2 rtn sel ) (setq msg (princ (cond (msg) ("\nSelect object: "))) rtn "" ) (while (progn (setq gr1 (grread nil 14 2) gr2 (cadr gr1) gr1 (car gr1) ) (cond ( (= 3 gr1) (if (ssget gr2) ;; nentselp is slow for xrefs (if (setq sel (ssget gr2 ftr)) (progn (setq rtn (ssname sel 0)) nil) (princ (strcat "\nInvalid object selected." msg)) ) (princ (strcat "\nMissed, try again." msg)) ) ) ( (= 2 gr1) (cond ( (< 31 gr2 127) (setq rtn (strcat rtn (princ (chr gr2)))) ) ( (= 13 gr2) nil ) ( (and (= 8 gr2) (< 0 (strlen rtn))) (setq rtn (substr rtn 1 (1- (strlen rtn)))) (princ "\010 \010") ) ( t ) ) ) ( (= 25 gr1) nil ) ( t ) ) ) ) rtn)
(LM:select-or-text "\nSelect a Line: " '((0 . "LINE")))
Thanks for the update LEE.
(princ "\010 \010")
(princ "\010")
@ Lee:Why do you use:Code: [Select](princ "\010 \010")Instead of:Code: [Select](princ "\010")?
Quote from: roy_043 on August 27, 2013, 06:14:18 AM@ Lee:Why do you use:Code: [Select](princ "\010 \010")Instead of:Code: [Select](princ "\010")?IIRC, in earlier versions of AutoCAD, printing a backspace character to the command-line would only move the cursor back one position, without actually erasing the last character, hence you would need to print a space to 'overwrite' the last character and then move the cursor back again.
I want to prompt the user to select an object or enter text at the command prompt. I am expanding a routine that currently prompts the user to enter a number at the command prompt. However the drawing may have a block that has the number in it already so I want the option to select to the block which I can grab the number from.