Jump to content

Change color of object not in current space?


ILoveMadoka

Recommended Posts

This code

 

(setq ss (ssget "X" '((62 . 5)))) 

 

finds all blue objects across multiple sheets inside a drawing.  (I don't know the VLA equivalent..)

 

How do I change the color to BYLAYER for all objects in the selection set?

 

When I've tried CHANGE/CHPROP I get errors..

 

## were not in current space

 

I am anticipating that it's something simple but it evades me at the moment...

 

Link to comment
Share on other sites

Have to use entmod usually you cant use (command "_.comand" SS "") on things you cant select with a mouse click. so like things on another tab or inside a block.

 

(defun C:test (/ ss)
  (if (setq ss (ssget "X" '((62 . 5)))) 
    (foreach ent (reverse (mapcar 'cadr (ssnamex ss)))
      (entmod (append (entget ent) (list '(62 . 256))))
    )
  )
  (princ)
)

 

-edit

might also need a regen

Edited by mhupp
Link to comment
Share on other sites

Thank you...

 

If I have the code below..

 

(setq ss1 (ssget "_X" (list (cons 62 5))))

 

How do I add a second color to the selection set?

I want to pick both blue and cyan objects..

 

I tried this

 

(setq ss1 (ssget "_X" (list (cons 62 5)(cons 62 4))))

 

I know there is some sort of separator in there somehow..

Link to comment
Share on other sites

As a hint....

 

(setq ss1 (ssget "_X" (list (cons 62 5)(cons 62 4))))

 

the selection set filter 'list' is a logical AND for each item - so you are looking for an object colour 5 AND colour 4...

Link to comment
Share on other sites

Needs to be "OR" because an item can't be both colors. so it won't find anything with and.

http://lee-mac.com/ssget.html#logical

 

(defun C:test (/ ss)
  (if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>"))))
    (foreach ent (reverse (mapcar 'cadr (ssnamex ss)))
      (entmod (append (entget ent) (list '(62 . 256))))
    )
    (prompt "\nNothing Found")
  )
  (princ)
)

 

Edited by mhupp
update code
Link to comment
Share on other sites

(if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>"))))

 

This does not work for me.

It's missing a paren and if I manually close it I get *Cancel*

 

This also returns a *Cancel*

(if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>")))))

 

 

This works

 

(setq ss1 (ssget "_X" (list (cons 62 5)))) 
(setq ss2 (ssget "_X" (list (cons 62 4)))) 
(setq ss3 (acet-ss-union (list ss1 ss2)))

 

But is it the "best way?"

 

I was attempting to select everything that is BLUE and everything that is CYAN in a single SSGET statement.

Is that not possible?

 

Link to comment
Share on other sites

This might be your problem:

 

(if 

 

Your second line:

(if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>")))))

 

 

read as "If SS is somethng do... nothing" - you'll maybe be wanting to remove the 'if' or before your closing bracket tell the LISP what to do:

 

(if (setq ss (ssget "_X" '((-4 . "<OR") (62 . 5) (62 . 4) (-4 . "OR>"))))
  (progn  
  
;; do all your clever stuff here if selection set finds anything blue or cyan  
  
  )
  (progn
  
;; do all your other clever stuff here if nothing is blue or cyan  
  
  )
)

 

 

often selection set is enclosed with an 'if' so that the LISP doesn't fail if there is nothing valid selected - you can go off and do something like an error message to the user

  • Agree 1
Link to comment
Share on other sites

2 hours ago, ILoveMadoka said:

But is it the "best way?"

 

 

See my updated code. I only posted the if line so you could replace it in the original code. sorry i didn't make the more clear.

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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