bababarghi Posted April 12, 2017 Share Posted April 12, 2017 Hi all, I have following lisp which selects all the texts containing "xxx": (defun foo (text) (sssetfirst nil (ssget "_x" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "*TEXT") (cons 1(setq text(strcat "*" (strcase text) "*,*" (strcase text T) "*"))) '(-4 . "AND>") '(-4 . "<AND") '(0 . "MULTILEADER") (cons 304 text) '(-4 . "AND>") '(-4 . "OR>") ) ) ) (princ) ) (foo "xxx") What I need to do is to change selected items colour. I was hoping someting like: (command ".CHPROP" "Color" "5" "" "") to do the job but obviously that is not the case. Quote Link to comment Share on other sites More sharing options...
SunnyTurtle Posted April 12, 2017 Share Posted April 12, 2017 (edited) Your almost there just need to assign a variable (tss) to the selection set and combine the two. (defun foo (text) (sssetfirst nil (setq tss (ssget "_x" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "*TEXT") (cons 1(setq text(strcat "*" (strcase text) "*,*" (strcase text T) "*"))) '(-4 . "AND>") '(-4 . "<AND") '(0 . "MULTILEADER") (cons 304 text) '(-4 . "AND>") '(-4 . "OR>") ) ) ) (princ) )) (command "CHPROP" tss "" "Color" "5" "" "") Edited April 12, 2017 by SunnyTurtle prentices missing Quote Link to comment Share on other sites More sharing options...
bababarghi Posted April 12, 2017 Author Share Posted April 12, 2017 Your almost there just need to assign a variable (tss) to the selection set and combine the two. (defun foo (text) (sssetfirst nil (setq tss (ssget "_x" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "*TEXT") (cons 1(setq text(strcat "*" (strcase text) "*,*" (strcase text T) "*"))) '(-4 . "AND>") '(-4 . "<AND") '(0 . "MULTILEADER") (cons 304 text) '(-4 . "AND>") '(-4 . "OR>") ) ) ) (princ) )) (command "CHPROP" tss "" "Color" "5" "" "") Command: (foo "xxx") ; error: too many arguments Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 12, 2017 Share Posted April 12, 2017 @SunnyTurtle, Always try to void global variables unless you are in need of this process. Although I prefer using the iteration through each entity but here I am following your way for your learning or so. (defun foo (text / ss) (sssetfirst nil (setq ss (ssget "_x" (list '(-4 . "<OR") '(-4 . "<AND") '(0 . "*TEXT") (cons 1 (setq text(strcat "*" (strcase text) "*,*" (strcase text T) "*"))) '(-4 . "AND>") '(-4 . "<AND") '(0 . "MULTILEADER") (cons 304 text) '(-4 . "AND>") '(-4 . "OR>") ) ) ) ) ss ) (if (setq ss (foo "xxx")) (command ".CHPROP" ss "" "Color" "5" "") ) Quote Link to comment Share on other sites More sharing options...
bababarghi Posted April 12, 2017 Author Share Posted April 12, 2017 Thanks Tharwat. Code is working now. Is it an easy fix if I want the code search through Attributes as well?! After running the code above, I realised some of the "xxx" strings are attributes (unfortunately) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 12, 2017 Share Posted April 12, 2017 Thanks Tharwat. Code is working now. You're welcome anytime. Is it an easy fix if I want the code search through Attributes as well?! After running the code above, I realised some of the "xxx" strings are attributes (unfortunately) Attribute Definitions or Attributes in blocks? Quote Link to comment Share on other sites More sharing options...
SunnyTurtle Posted April 12, 2017 Share Posted April 12, 2017 @SunnyTurtle, Always try to void global variables unless you are in need of this process. Thank Tharwat you are right. I make that mistake too often and should be trying to improve that. Quote Link to comment Share on other sites More sharing options...
bababarghi Posted April 12, 2017 Author Share Posted April 12, 2017 Attribute Definitions or Attributes in blocks? Attributes in blocks. I need to hightlight them in RED (true color) in order to stand out in hardcopy prints. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 12, 2017 Share Posted April 12, 2017 Attributes in blocks. I need to hightlight them in RED (true color) in order to stand out in hardcopy prints. Should iterate through each Attribute in blocks to be able to change Color, String, Text Height .... etc. 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.