Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Kent1Cooper
en respuesta a: vporrash141089


@vporrash141089 wrote:

.... I need to open 100 different drawings one by one and select a hatch and change it from color red to bylayer which is magenta color 6. also I need to select a line/polyline which is in color green and need to manually change it to color 82.

....


 

If you're going to select manually, and know which things you're after, you could just build the color assignments in:

 

(defun c:cc (/ ss)
 (prompt "Select Hatch object(s) to change to ByLayer color.")
 (if (setq ss (ssget))
   (command "_.ChProp" ss "" "_C" "ByLayer" ""))
 (prompt "Select Line/Polyline object(s) to change to color 82.")
 (if (setq ss (ssget))
   (command "_.ChProp" ss "" "_C" 82 ""))

 (princ)

)

 

Assuming that by red and green you mean specifically color numbers 1 and 3 [not other possibilities such as 10 and 90], you could prevent yourself from picking the wrong thing(s) with filtering in the (ssget) functions:

 

(defun c:cc (/ ss)
 (prompt "Select Hatch object(s) to change to ByLayer color.")
 (if (setq ss (ssget '((0 . "HATCH") (62 . 1)))); only red Hatch object(s)
   (command "_.ChProp" ss "" "_C" "ByLayer" ""))
 (prompt "Select Line/Polyline object(s) to change to color 82.")
 (if (setq ss (ssget '((0 . "*LINE") (62 . 3)))); only green Line/Polyline object(s)

   (command "_.ChProp" ss "" "_C" 82 ""))

 (princ)

)

 

[In the second half, that would also accept Splines, Xlines & Mlines, but with some more code could restrict itself to only Lines or Polylines.]  And you could have it restricted to a single object in each case, and you could have it forbid selection if the Layer is locked, and various other enhancements.

Kent Cooper, AIA