Here is a simple AutoLISP program I wrote that creates new layers in the format 'House - Walls - Structure' (for example).
(defun SCASE (instr /) ;sentence case
(strcat (strcase (substr instr 1 1)) (substr instr 2)))
; - - - - - -
(defun C:LNR (/ lname inp) ;LayerNameR
(setq div " - "
inp (scase (getstring T "Enter first part:")))
(while (/= inp "")
(if lname
(setq lname (strcat lname div inp))(setq lname inp))
(setq inp (scase (getstring T "Enter next part:"))))
;exit while loop - put color picker here
(command "-layer" "n" lname "S" lname "")
(princ))
What I want to do is be able to pick a color for the new layer using the standard 256 color picker. It is beyond my simple lisp skills but it must be possible - musn't it? A pop-up color picker?
Any suggestions?
Solved! Go to Solution.
Solved by ВeekeeCZ. Go to Solution.
Type 01
(defun C:LL () ( c:LAYER_UP ))
(defun c:LAYER_UP ()
(command "layer" "m" "LAYER NAME1" "lt" "continuous" "" "c" "1" "" "") ; 1 RED
(command "layer" "m" "LAYER NAME2" "lt" "continuous" "" "c" "2" "" "") ; 2 YELLOW
(command "layer" "m" "LAYER NAME3" "lt" "continuous" "" "c" "3" "" "") ; 3 GREE COLOR
(command "layer" "m" "LAYER NAME4" "lt" "continuous" "" "c" "4" "" "") ; 3 CYAN COLOR
(command "layer" "m" "LAYER NAME5....N+1NAME" "lt" "continuous" "" "c" "5" "" "") ; 3 BLUE COLOR
(princ)
)
Type 02
Thanks for that - I didn't think of looking in the obvious place. Here's my modified code:
; - - - - - -
(defun SCASE (instr /) ;sentence case
(strcat (strcase (substr instr 1 1)) (substr instr 2)))
; - - - - - -
(defun C:LNR (/ lname inp) ;LayerNameR
(setq div " - "
inp (scase (getstring T "Enter first part:")))
(while (/= inp "")
(if lname
(setq lname (strcat lname div inp))(setq lname inp))
(setq inp (scase (getstring T "Enter next part:"))))
(setq col (acad_colordlg 5 nil)) ; defaults to Blue with no bylayer or byblock otions
(command "-layer" "n" lname "S" lname "C" col "" "")
(princ))
; - - - - - -
Works well.
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
I tried to bug it but it worked anyway. I entered the same name, changed the color and it silently changed the color on that name. If I cancelled the color dialog box it made the color the default (blue in this case).
I know it doesn't follow the structure you show, but it works for me.
it will do for now!
Thanks for your comment anyway - I consider it in future programs.
Jez
Can't find what you're looking for? Ask the community or share your knowledge.