Originally Posted by
Phil Gravel
It would be easier (in fact, I've scripted something already for myself), but I have some die-hard drafters that have been using these shortcuts for the last century or so. I'd like not to break the habit, if possible. Which leads us back to getting the user input as a variable.
Always happy to further perpetuate inefficiency :
You can use simple LISP routines as such:
Code:
(defun c:1 () (_ChangeSsColor 1))
(defun c:2 () (_ChangeSsColor 2))
(defun c:3 () (_ChangeSsColor 3))
(defun c:4 () (_ChangeSsColor 4))
(defun c:5 () (_ChangeSsColor 5))
(defun c:6 () (_ChangeSsColor 6))
(defun c:7 () (_ChangeSsColor 7))
(defun c:8 () (_ChangeSsColor 8))
(defun c:9 () (_ChangeSsColor 9))
(defun c:10 () (_ChangeSsColor 10))
;;; ... And so on
... Which supply the color (the command name) to the dependent sub-function, changing the color of a valid selection set, and supports undo functionality:
Code:
(vl-load-com)
(defun _ChangeSsColor (color / *error*)
(princ "\nChanger la couleur: ")
(defun *error* (msg)
(and oldNomutt (setvar 'nomutt oldNomutt))
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ msg)) ; Fatal error, display it
)
(princ)
)
((lambda (acDoc oldNomutt / ss)
(vla-startundomark acDoc)
(princ "\nSélectionnez les objets à changer de couleur: ")
(setvar 'nomutt 1)
(if (setq ss (ssget "_:L"))
(progn
(vlax-for x (setq ss (vla-get-activeselectionset acDoc))
(vl-catch-all-apply 'vla-put-color (list x color))
)
(vla-delete ss)
(*error* nil)
)
(*error* "\n** Rien sélectionné ** ")
)
)
(vla-get-activedocument (vlax-get-acad-object))
(getvar 'nomutt)
)
)
Rather than load this into every drawing, consider adding a robust AUTOLOAD Statement instead:
Code:
(autoload "<SomeFileName>.lsp" '("1" "2" "3" "4" "5" "6" "7" "8" "9" "10"))