Jump to content

How to apply CHPROP command on selected items


bababarghi

Recommended Posts

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.

Link to comment
Share on other sites

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 by SunnyTurtle
prentices missing
Link to comment
Share on other sites

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" "" "")

 

 

:unsure:

Command: (foo "xxx")
; error: too many arguments

Link to comment
Share on other sites

@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" "")
 )

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...