I'll be really interested to see if anyone else has different versions of this type of lisp since this is the vast majority of the type of lisp I do.
So here's three routines.
Code:
(defun trapUP (errmsg)
(setvar "clayer" oldlayer)
(setvar "plinegen" oldgen)
(setvar "plinewid" oldwid)
(command "-linetype" "set" "Bylayer" "")
(setq *error* temperr)
(prompt "\nResetting System Variables ")
(princ)
)
This is a trap that is referenced in each line command I write. UP stands for Utility Proposed. Can rename it to whatever you want, or just leave it if you're afraid to play with it. Essentially the trap is used so that if the user escapes during the command variables are reset. If the users hits return when they are done drawing the variables reset as part of the line's routine, thus the trap is the other end of making sure they reset properly.
Code:
(DEFUN C:SAS()
(setq cancel *error*)
(setq *error* trapUP)
(setq oldlayer (getvar "clayer"))
(setq oldgen (getvar "plinegen"))
(setq oldwid (getvar "plinewid"))
(setvar "plinegen" 1)
(setvar "plinewid" 0.0)
(COMMAND "-LAYER" "MAKE" "UP-SS" "COLOR" "72" "" "Ltype" "U-SS" "" "lweight" ".6" "" "")
(COMMAND "PLINE" )
(while (> (getvar "CMDACTIVE") 0) (command pause))
(setvar "clayer" oldlayer)
(setvar "plinegen" oldgen)
(setvar "plinewid" oldwid)
(command "-linetype" "set" "Bylayer" "")
(setq *error* temperr)
(princ)
)
Basically what you're looking for here. This is an undefined line command that doesn't describe pipe size.
Code:
(DEFUN C:4SS()
(setq cancel *error*)
(setq *error* trapUP)
(setq oldlayer (getvar "clayer"))
(setq oldgen (getvar "plinegen"))
(setq oldwid (getvar "plinewid"))
(setvar "plinegen" 1)
(setvar "plinewid" 0.33)
(COMMAND "-LAYER" "MAKE" "UP-SS" "COLOR" "72" "" "Ltype" "U-SS" "" "lweight" ".6" "" "")
(COMMAND "-linetype" "SET" "U-SS-4" "")
(COMMAND "PLINE" )
(while (> (getvar "CMDACTIVE") 0) (command pause))
(setvar "clayer" oldlayer)
(setvar "plinegen" oldgen)
(setvar "plinewid" oldwid)
(command "-linetype" "set" "Bylayer" "")
(setq *error* temperr)
(princ)
)
This is only slightly different in that before it runs the line command it sets it to the linetype you want. The end result is that your overall utility layer has a linetype that may not be used at all if you're almost always describing pipe sizes (like we do), but all the same utilities with different sizes are on the same layer. This makes it easy to isolate the layer to see all the lines you want.
If you care about lineweight I think the plinewid variable messes with it, and you can delete that line of the code. Personally (and maybe someone wants to correct me) I'm not quite sure why people want to set weights to layers instead of just adjusting the width. I think the weights being set in my lines are useless because I also set the width to what I want, and I believe the plinewid variable has to be 0 for the weight to be factored in.
On this topic here's a bonus: http://www.lee-mac.com/totallengthandarea.html
This routine will allow you to measure all the selected lines or area instantly. It goes really well with isolating a utility and then grabbing all the lines.