CADNADIAN Posted June 23, 2016 Share Posted June 23, 2016 (edited) Is there a lisp to simply change the height of a specific text in a layer? I wrote this so far, but having troubles. (defun C:CommandName () (command "_.chprop" (ssget "_X" '((8 . "layer1"))) "" ; complete selection "_ht" 1.5 ""); (princ) it asks to change the general properties and not the properties i want to change. Edited June 23, 2016 by rkmcswain added [CODE] tags Quote Link to comment Share on other sites More sharing options...
Happy Hobbit Posted June 23, 2016 Share Posted June 23, 2016 *not thoroughly tested* (defun c:test ( / entx ht i ss) (setq ht (getint "\nSpecify Text Height:")) (if (setq ss (ssget "_:L" '((-4 . "<and") (0 . "TEXT,MTEXT") (8 . "layer1") (-4 . "and>") ))) ;; Change "_X" to "_:L" to choose selected items (repeat (setq i (sslength ss)) (setq i (1- i)) (setq entx (entget(ssname ss i))) (entmod (subst (cons 40 ht) (assoc 40 entx) entx)) ) (princ "\No Text items on Layer1 Found") ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2016 Share Posted June 23, 2016 <... '((-4 . "<and") (0 . "TEXT,MTEXT") (8 . "layer1") (-4 . "and>")) ...> FWIW, note that the ssget filter list uses an implicit AND logic, meaning that the operators in your example are redundant. Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 23, 2016 Share Posted June 23, 2016 Hi Lee, Can you give an example when operators are needed? I can't figure this out. As for the OP's question, another option that would differ from Happy Hobbit's code would be a selection of source text/mtext entity. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 23, 2016 Share Posted June 23, 2016 Can you give an example when operators are needed? I can't figure this out. http://lee-mac.com/ssget.html#logical Quote Link to comment Share on other sites More sharing options...
Grrr Posted June 23, 2016 Share Posted June 23, 2016 http://lee-mac.com/ssget.html#logical Ahh, thanks! I get it now.. when different entities must be filtered by their specific properties - like circles with specific radius-R1 and arcs with specific radius-R2 (from your example). I never had to use it, but I think it would be useful for style filtering (dimstyles, tstyles, mleaderstyles... etc - all in one). Quote Link to comment Share on other sites More sharing options...
CADNADIAN Posted June 24, 2016 Author Share Posted June 24, 2016 *not thoroughly tested* (defun c:test ( / entx ht i ss) (setq ht (getint "\nSpecify Text Height:")) (if (setq ss (ssget "_:L" '((-4 . "<and") (0 . "TEXT,MTEXT") (8 . "layer1") (-4 . "and>") ))) ;; Change "_X" to "_:L" to choose selected items (repeat (setq i (sslength ss)) (setq i (1- i)) (setq entx (entget(ssname ss i))) (entmod (subst (cons 40 ht) (assoc 40 entx) entx)) ) (princ "\No Text items on Layer1 Found") ) (princ) ) Thank you so very much hobbit! It appears that the method of this routine prompts a selection of text from the user (select object)- and modifies the text based on another prompt (specify text height). Is there a way to simply have zero user interaction? By this i mean, if my company has a standard size of text that i want my text layer to be changed to without typing anything. Thats why i used the SSGET route Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 24, 2016 Share Posted June 24, 2016 Simple changes ; changes (defun c:text4 ( / entx ht i ss) (setq ht 4) ; rest the same Also no code verision FILTER TEXT APPLY then PROPERtIES text height 4 Quote Link to comment Share on other sites More sharing options...
Happy Hobbit Posted June 24, 2016 Share Posted June 24, 2016 Alternatively: Change (cons 40 [color="red"]ht[/color]) to (cons 40 [color="red"]4[/color]) Delete this line: [color="red"](setq ht (getint "\nSpecify Text Height:"))[/color] Remove ht from this: ( / entx[color="red"] ht [/color]i ss) Hello BIGAL what do you mean by code version? *EDIT* Best change this as well: '((-4 . "<and") (0 . "TEXT,MTEXT") (8 . "layer1") (-4 . "and>")) to '((0 . "TEXT,MTEXT") (8 . "layer1")) On the advice of Lee Mac.What he doesn't know about Autolisp isn't worth knowing! Quote Link to comment Share on other sites More sharing options...
CADNADIAN Posted June 25, 2016 Author Share Posted June 25, 2016 Alternatively: Change (cons 40 [color=red]ht[/color]) to (cons 40 [color=red]4[/color]) Delete this line: [color=red](setq ht (getint "\nSpecify Text Height:"))[/color] Remove ht from this: ( / entx[color=red] ht [/color]i ss) Hello BIGAL what do you mean by code version? *EDIT* Best change this as well: '((-4 . "<and") (0 . "TEXT,MTEXT") (8 . "layer1") (-4 . "and>")) to '((0 . "TEXT,MTEXT") (8 . "layer1")) On the advice of Lee Mac.What he doesn't know about Autolisp isn't worth knowing! Did you guys actually test this ? Its not working on my end. It cant even "appload" for some reason I think what BIGAL meant by "no code version" is that "text height" is a property that requires user interaction to edit, even when using a lisp routine. Quote Link to comment Share on other sites More sharing options...
BKT Posted June 26, 2016 Share Posted June 26, 2016 I just shuffled it around a bit, but it works for me: (defun c:test (/ ss i ed) (if (setq ss (ssget "_X" '((0 . "TEXT") (8 . "layer1")))) (progn (setq i 0) (repeat (sslength ss) (setq ed (entget (ssname ss i)) i (1+ i) ed (subst (cons 40 4.0) (assoc 40 ed) ed) ) (entmod ed) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Baber62 Posted July 12, 2016 Share Posted July 12, 2016 Is it possible to adjust this routine so that it can change text height of any text (single line text or multi line text) irrespective of the layer the text is in? No worries found on another post at http://www.cadtutor.net/forum/showthread.php?25756-Code-to-change-text-height. Thanks to Lee-Mac!! 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.