AutoLISP to show different floorplans of a building from different levels

AutoLISP to show different floorplans of a building from different levels

Anonymous
Not applicable
1,178 Views
8 Replies
Message 1 of 9

AutoLISP to show different floorplans of a building from different levels

Anonymous
Not applicable

Hi, my first post so I might no get everything right but bear with me please.


I used to be an intern for an architecture studio that used only AutoCAD and there I learned of AutoLISP.
They had a workflow as follows: Layers named 1level walls, 1level furniture, etc and 2level walls, 2level furniture etc. and so on and when they entered a command "gt"(go to) and a number (1,2,3 ...) all layers except the ones starting with that number were frozen -and they could quickly cycle trough the levels of that bulding.
 Only layer 0 remained always unfrozen and so could transfer info from one level to the other.

 

I spend the last few days searching for such a LISP but I had no luck finding one. If anyone knows of such can you link me to it or could anyone help me make one?

0 Likes
Accepted solutions (2)
1,179 Views
8 Replies
Replies (8)
Message 2 of 9

pendean
Community Legend
Community Legend
Any reason you are staying away from just using LAYERSTATE command, a tool designed to do what you want already in the program? here is an easy to follow tutorial https://allaboutcad.com/autocad-tutorial-save-and-use-layer-states-to-streamline-your-work/

Message 3 of 9

ВeekeeCZ
Consultant
Consultant
Accepted solution

Such LISP might be really simple:

 

 

(defun c:GT ( / f)

  (setq f (getstring "\nFloor: "))
  (command "_.layer"
	   "_t" "*"
	   "_s" "0"
	   "_f" (strcat "~*" f "*")
	   "")
  (princ)
  )

 

if the layers are named by pattern 1level -something, then the red part can look like (strcat "~" f "level *")

0 Likes
Message 4 of 9

Anonymous
Not applicable
Yes -I watched a few tutorials on layer states and tried them myself and it worked nicely but as far as I know as of now there's no quick command to change layer states and they have to be changed by a few clicks with the mouse which is too slow to be useful. anyway thanks for the suggestion!
0 Likes
Message 5 of 9

Anonymous
Not applicable
I had to watch a few tutorials on how to implement this but I got the hang of it and it worked like a charm. Thank you!
0 Likes
Message 6 of 9

Anonymous
Not applicable
Hi again. The LISP works nicely but as any design it met a need for improvement. How should the code be changed so it only freezes the layers of the other floors but not layers that do not belong to any floor -such as drafting, greenery and topography layers. As it is now the "gt" command freezes every layer except those that belong to the certain level and the 0 layer.
0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant

You know what... the LISP is really simple. All you need to be able to adjust it by yourself is to learn a few wildcards - HERE 

 

(command "_.layer"
	   "_that" "*"                     ;; thaw all layers
	   "_set" "0"                      ;; set the 0 layer current
	   "_freeze" (strcat "~*" f "*")   ;; freeze all but those containing your number
	
0 Likes
Message 8 of 9

Anonymous
Not applicable
Accepted solution
Thanks for the link and short explanation. I was able to figure out some things and managed to write a code that works as I wanted. Here it is:
(defun c:TT ( / f)

(setq f (getstring "\nFloor: "))
(command "_.layer"
"_s" "0"
"_f" (strcat "*lvl *")
"_t" (strcat f "lvl *")
"")
(princ)
)
Message 9 of 9

ВeekeeCZ
Consultant
Consultant

Good!

Just consider thawing the "0" layer prior to setting it current. It will crash if happen to be frozen.