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:

.... If there is only one hatch and one green line element shouldn't there be a way to have the code select it and change it for me?

....


 

Yes.  You can remove the prompts to the User, and put an "_X" into the (ssget) functions to have the routine look for itself:

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

 

The X means look through the entire drawing, so this depends on your being correct that there's only one of each such object, or you could have things changed that you don't want.

 

Another thing to be aware of:  The X in (ssget) will see things anywhere in the drawing, but the CHPROP command will see only things in the current space.  If this might be run in a drawing in which the target objects may not be in the current space, that can be accounted for with some different code.

 

[Same caveat as before about *LINE objects.]

Kent Cooper, AIA