Author Topic: Select all objects on a color  (Read 6683 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
Select all objects on a color
« on: May 23, 2005, 07:51:50 PM »
I've seen a routine like this on the Swamp before, just can't seem to find it.  Can anyone help?  Select all objects on a color and change layer.
Thanks,

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Select all objects on a color
« Reply #1 on: May 23, 2005, 08:17:42 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

danny

  • Guest
Select all objects on a color
« Reply #2 on: May 23, 2005, 08:32:55 PM »
CAB,
That is a great routine, and I also like quick select.  But, I need to be able to run it in a script file.  Sorry, I should have been more specific.

danny

  • Guest
Select all objects on a color
« Reply #3 on: May 24, 2005, 02:48:38 PM »
o.k I tried this, but got a bad ssget list.  What did I do wrong?  Just trying to get all object on color 8 and change them to layer xxfine.
Code: [Select]
(defun c:c2lay ()
  (setq sset
(ssget
  "x"
  '((62.8))
)
  )
  (if sset
    (repeat (sslength sset)
      (command "_.chprop" sset "" "layer" "xxfine" "")
    )
  )
)

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Select all objects on a color
« Reply #4 on: May 24, 2005, 02:52:08 PM »
Quote from: danny
Code: [Select]
'((62.8))
must be:
Code: [Select]
'((62 . 8))note the spaces...
Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

whdjr

  • Guest
Select all objects on a color
« Reply #5 on: May 24, 2005, 03:00:58 PM »
You also have to step thru each item in a selection set using nth.

Try this:
Code: [Select]
(defun c:c2lay (/ sset len)
  (setq sset (ssget "x" '((62 . 8))))
  (if sset
    (repeat (setq len (sslength sset))
      (setq len (1- len))
      (command "_.chprop" (nth len sset) "" "layer" "xxfine" "")
    )
  )
)

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Select all objects on a color
« Reply #6 on: May 24, 2005, 03:06:15 PM »
ahem...
Code: [Select]
(if sset
 (command "_.chprop" sset "" "layer" "xxfine" "")
)
Should be enough

Cheers
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

whdjr

  • Guest
Select all objects on a color
« Reply #7 on: May 24, 2005, 03:08:12 PM »
Yeah that would work as well.  I didn't think of that I just fixed his repeat problem.

danny

  • Guest
Select all objects on a color
« Reply #8 on: May 24, 2005, 03:20:42 PM »
So essentially, this is all I need?
Code: [Select]
(defun c:c2lay ()
  (setq   sset
    (ssget
      "x"
      '((62 . 8))
    )
  )
  (if sset
    (command "_.chprop" sset "" "layer" "xxfine" "")  
  )
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Select all objects on a color
« Reply #9 on: May 24, 2005, 03:24:33 PM »
As long as it's not 'bylayer' :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
Select all objects on a color
« Reply #10 on: May 24, 2005, 03:25:38 PM »
Yup!

However it is nice to localize your variables:
Code: [Select]
(defun c:c2lay (/ sset)

danny

  • Guest
Select all objects on a color
« Reply #11 on: May 24, 2005, 03:29:30 PM »
Quote
As long as it's not 'bylayer'

oh darn... Just noticed that too.  How can I select colors even if its 'bylayer'?

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Select all objects on a color
« Reply #12 on: May 24, 2005, 05:52:50 PM »
You need to make a list of layers that are of the color you want to filter.....Someone, coulda even been me, posted something that does this sometime in the past year or so. Lemme check......

Jeff_M

  • King Gator
  • Posts: 4099
  • C3D user & customizer
Select all objects on a color
« Reply #13 on: May 24, 2005, 06:05:07 PM »
OK, here's one I made up that also catches all entities within blocks...... uses ActiveX methods & proporties and no selection set.

After thinking about this, if you want to keep trying your own solution I'm not posting the code here. If you want to see and/or use it, I'm posting it to the Lilly Pond

danny

  • Guest
Select all objects on a color
« Reply #14 on: May 24, 2005, 07:26:55 PM »
Jeff,
I was thinking about trying ActiveX, if plain lisp didn't work.  I wish I had enough time to learn this method.  Eventually I'll get there...Thanks to the Swamp for everthing, I've become twice as efficient.  Well...I do spend a lot of time browsing around in here. :)
So, if I had this list
Code: [Select]
WHITE = _XBOLD
YELLOW = _BOLD
CYAN = _MED
RED = _FINE
MAGENTA = _XFINE
GREY = _XXFINE

how or where would I input this in your code?