ktbjx Posted March 14, 2017 Share Posted March 14, 2017 how do i get the TEXT content and put it as elevation on objects i'll be slecting? (defun c:q1 (/ txt1 q1 ss) (setq ss (ssget "_C" '((0 . "*TEXT")))) (cdr (assoc 1 (entget (ssname ss (setq txt1 0))))) (prompt "\nSELECT OBJECTS") (setq sss (ssget "_:L")) (command"_.CHANGE" sss "" "_P" "_E" txt1) ) Quote Link to comment Share on other sites More sharing options...
tombu Posted March 14, 2017 Share Posted March 14, 2017 Get the TEXT or MTEXT content with (setq txt(vla-get-TextString(vlax-ename->vla-object (car (entsel))))) Not sure what you're trying to do with it. Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 14, 2017 Share Posted March 14, 2017 (edited) Some guessing: (defun c:q1 ( / LeaveNumbersAndDots txt enx n SS ) (defun LeaveNumbersAndDots (str) (if (and (eq 'STR (type str)) (setq str (vl-remove-if-not '(lambda (c) (<= 46 c 57)) (vl-string->list str))) ) (vl-list->string str) ) ); defun LeaveNumbersAndDots (cond ( (not (setq txt (car (entsel "\nPick text with numerical content: ")))) (alert "\nNothing selected.") ) ( (not (wcmatch (cdr (assoc 0 (setq enx (entget txt)))) "*TEXT")) (alert "\nThis is not a text.") ) ( (not (numberp (setq n (read (setq txt (cdr (assoc 1 enx))))))) (alert (strcat "\nThis text has no full numerical content: \nCurrently it is: \"" txt "\" \nIt must be in the following format: \"" (cond ((LeaveNumbersAndDots txt)) ("123.4")) "\"." ) ) ) ( (not (and (princ "\nSelect objects to change their elevation: ") (setq SS (ssget "_:L")))) (alert "\nNothing selected.") ) ( (mapcar '(lambda (enx) (cond ( (assoc 38 enx) (entmod (append enx (list (cons 38 n)))) ) ( (entmod (mapcar '(lambda (x) (if (member (car x) '(10 11)) (reverse (cons n (cdr (reverse x)))) x) ) enx)) ) ) ) (mapcar 'entget (apply 'append (mapcar '(lambda (x) (if (= 3 (car x)) (list (cadr x)))) (ssnamex SS)))) ) ) ); cond (princ) ); defun Edited March 15, 2017 by Grrr Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 14, 2017 Share Posted March 14, 2017 ( (not (numberp (setq n (read (cdr (assoc 1 enx)))))) (alert "\nThis text has no numerical content.") ) Hi, Your alert sentence is not that entirely correct since numberp function would return nil for such a string. eg: "abc123" (defun HasNoNumber-p (str) (not (vl-some '(lambda (no) (< 47 no 57)) (vl-string->list str))) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 14, 2017 Share Posted March 14, 2017 Hi Tharwat, Yes: my intention was to check only for numerical characters inside the text content (I thought that would be the required format). And yes, my alert message is not entirely correct (due some lack of english). Anyway, like you said the text content could be re-formatted: ; _$ (LeaveNumbers "Leave 251, 900 and 841 numbers please.") -> "251900841" (defun LeaveNumbers (str) (apply 'strcat (mapcar 'chr (vl-remove-if-not '(lambda (c) (< 47 c 58)) (vl-string->list str)))) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 14, 2017 Share Posted March 14, 2017 I guess this thread is somehow related to THIS ONE Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 14, 2017 Share Posted March 14, 2017 ; _$ (LeaveNumbers "Leave 251, 900 and 841 numbers please.") -> "251900841" (defun LeaveNumbers (str) (apply 'strcat (mapcar 'chr (vl-remove-if-not '(lambda (c) (< 47 c 58)) (vl-string->list str)))) ) Both are correct but shorter and direct. (defun LeaveNumbers (str) (vl-list->string (vl-remove-if-not '(lambda (c) (< 47 c 58)) (vl-string->list str))) ) Quote Link to comment Share on other sites More sharing options...
ktbjx Posted March 15, 2017 Author Share Posted March 15, 2017 Some guessing: (defun c:q1 ( / txt enx n SS ) (cond ( (not (setq txt (car (entsel "\nPick text with numerical content: ")))) (alert "\nNothing selected.") ) ( (not (wcmatch (cdr (assoc 0 (setq enx (entget txt)))) "*TEXT")) (alert "\nThis is not a text.") ) ( (not (numberp (setq n (read (cdr (assoc 1 enx)))))) (alert "\nThis text has no numerical content.") ) ( (not (and (princ "\nSelect objects to change their elevation: ") (setq SS (ssget "_:L")))) (alert "\nNothing selected.") ) ( (mapcar '(lambda (x / enx) (cond ( (= 3 (car x)) (setq enx (entget (cadr x))) (entmod (append enx (list (cons 38 n)))) ) ) ) (ssnamex SS) ) ) ); cond (princ) ); defun thank you!. i tried it, and only polylines elevation is changed, but not LINES (Start z End Z), Leader (Vertex Z), Text (Position Z). how can i add it on your lisp? i dont wanna ruin your code Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 15, 2017 Share Posted March 15, 2017 i tried it, and only polylines elevation is changed, but not LINES (Start z End Z), Leader (Vertex Z), Text (Position Z). how can i add it on your lisp? i dont wanna ruin your code I've modified the code in post #3, should work better - but I can't guarantee that its flawless. Quote Link to comment Share on other sites More sharing options...
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.