samifox Posted September 9, 2012 Posted September 9, 2012 hi runing autocad 2010, i want to create a keystroke to hide /show a specific layer, how can i do it? Thanks Shay Quote
Dadgad Posted September 9, 2012 Posted September 9, 2012 There are a bunch of good tools for such tasks on the LAYERS2 toolbar. LAYISO and LAYWALK specifically would be good choices. Quote
BlackBox Posted September 9, 2012 Posted September 9, 2012 (edited) i want to create a keystroke to hide /show a specific layer, how can i do it? Quick example: (defun c:FOO (/ layerName layerData) (if (and [color=seagreen] ;; If the current layer is not the same as the pre-defined ;; layer to be toggled[/color] (/= (getvar 'clayer) (setq layerName "LayerName")) [color=seagreen] ;; And, the pre-defined layer exists[/color] (setq layerData (tblsearch "layer" layerName)) ) [color=seagreen] ;; Then, use the -LAYER Command to toggle the display[/color] (command "._-layer" [color=seagreen] ;; Based upon the layer's current display setting, ;; Where DXF 70 represents the Freeze/Thaw status. ;; If, thawed, freeze... If frozen, thaw[/color] (if (= 0 (cdr (assoc 70 layerData))) "freeze" "thaw" ) layerName "" ) [color=seagreen];; Else, do nothing, as the pre-defined layer is either ;; the same as the current layer, or the layer does not exist[/color] ) [color=seagreen];; Silent exit[/color] (princ) ) Edited September 9, 2012 by BlackBox Quote
samifox Posted September 9, 2012 Author Posted September 9, 2012 dadgad: there is specific layer i want to hide/show , using layerwalk ans isolation assume i dont know the layer identity renderman please be more step by step'ed as im not fimiliar with autocad coding.. Thanks Quote
BlackBox Posted September 9, 2012 Posted September 9, 2012 renderman please be more step by step'ed as im not fimiliar with autocad coding.. Certainly, perhaps the comments added to the code example here will better explain what the code is doing. dadgad: there is specific layer i want to hide/show , using layerwalk ans isolation assume i dont know the layer identity ... I know that this was addressed to Dadgad, but this comment changes the approach I would have used in the sample above. Instead, simply consider adding an item to your ACAD.PGP file, which would create a keyboard shortcut for activating the LAYFRZ, and LAYERP Commands. HTH Quote
Lee Mac Posted September 9, 2012 Posted September 9, 2012 I want to create a keystroke to hide /show a specific layer, how can i do it? Perhaps use something like: (defun c:[color=green][highlight]aa[/highlight][/color] ( ) (freezethawlayer "[color=red][highlight]MyLayer[/highlight][/color]")) (defun freezethawlayer ( name / dx en ) (if (= (strcase (getvar 'clayer)) (strcase name)) (princ "\nCannot freeze the current layer.") (if (setq en (tblobjname "LAYER" name)) (setq en (entget en) dx (assoc 70 en) en (entmod (subst (cons 70 (boole 6 1 (cdr dx))) dx en)) ) (princ (strcat "\nLayer " name " doesn't exist.")) ) ) (princ) ) Alter the name of the layer in [highlight]red[/highlight] and the command name ('aa') in [highlight]green[/highlight] to suit your requirements. If you need different commands to freeze/thaw different layers, just add another line similar to the first line, e.g.: (defun c:[color=green][highlight]bb[/highlight][/color] ( ) (freezethawlayer "[color=red][highlight]AnotherLayer[/highlight][/color]")) Here, the command would be '[highlight]bb[/highlight]' and the layer name is '[highlight]AnotherLayer[/highlight]' Here are instructions on how to load & run the code: http://www.cadtutor.net/forum/showthread.php?1390-How-to-use-the-LISP-routines-in-this-archive Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.