Firstly, many thanks to everyone who contributes to this site, it is an immensely helpful source of info.
I have been using AutoCAD for many years and have recently started to play around with AutoLISP to try and streamline some repetitive commands, I can generally construct simple routines but have bitten off more than I can chew with this one.
I would like to write a LISP that will create layers within an open drawing based on a proposed buildings max story height while factoring in the possibility of a basement floor and/or split ground floor (upper/Lower). The layer names are floor specific and would be as follows:
x =floor number (-1 = Basement, 0 =Ground, 1 = First etc)
NLP x Walls
NLP x Windows
NLP x Rooms
NLP x Balcs
NLP x Detailing
(one set of layers per floor)
Setq: user inputs
basement (Yes/No)
Splitgrnd (Yes/No)
floorno (numeric value based on total number of floors)
Setq: program
floornoabsolute (based on user inputs to return number of top floor)
n.b. I appreciate that the routine is probably cumbersome and could be streamlined but please ignore this for now as I am using it as a teaching aid and will learn how to do this in due course, for now I would just like to know a few things that I am struggling with.
My LISP so far:
(defun c:NLPADDLAYERSTEST ( / floorno basement splitgrnd floornoabsolute)
(initget 1 "Yes No")
(setq basement (getkword "\nDoes the Scheme have a basement? (Yes/No): ")
)
(cond
((= basement "Yes") (command "layer" "n" "NLP -1 Walls" "n" "NLP -1 Windows" "n" "NLP -1 Rooms" "n" "NLP -1 Balcs" "n" "NLP -1 Detailing" ""))
)
(initget 1 "Yes No")
(setq splitgrnd (getkword "\nIs the ground floor split into upper and lower? (Yes or No): ")
)
(if (= splitgrnd "Yes")
(command "layer" "n" "NLP 0U Walls" "n" "NLP 0U Windows" "n" "NLP 0U Rooms" "n" "NLP 0U Balcs" "n" "NLP 0U Detailing" "n" "NLP 0L Walls" "n" "NLP 0L Windows" "n" "NLP 0L Rooms" "n" "NLP 0L Balcs" "n" "NLP 0L Detailing" "")
(command "layer" "n" "NLP 0 Walls" "n" "NLP 0 Windows" "n" "NLP 0 Rooms" "n" "NLP 0 Balcs" "n" "NLP 0 Detailing" "")
)
(initget 1)
(setq floorno (getreal "\nHow many stories in the proposed scheme? (max if multiple buildings): ")
floornoabsolute (cond
((and (= basement "No") (= splitgrnd "No") ("!floorno"-1)))
((and (= basement "Yes") (= splitgrnd "Yes") ("!floorno"-3)))
((and (= basement "Yes") (= splitgrnd "No") ("!floorno"-2)))
((and (= basement "No") (= splitgrnd "Yes") ("!floorno"-2)))
)
Unwritten part of program
)
)
Question 1
In the floornoabsolute set of conditions what would be the correct syntax in order to have the program return a value of floorno - number. As you can see I have it as ("!floorno"-2) but beleive that is incorrect.
Question 2
Would the following be the correct way to set a value for floornoabsolute? (excluding the fact that the part from the previous question is wrong)
(setq floornoabsolute (cond
((and (= basement "No") (= splitgrnd "No") ("!floorno"-1)))
((and (= basement "Yes") (= splitgrnd "Yes") ("!floorno"-3)))
((and (= basement "Yes") (= splitgrnd "No") ("!floorno"-2)))
((and (= basement "No") (= splitgrnd "Yes") ("!floorno"-2)))
)
Question 3
As I am still learning my initial approach to the rest of the code was going to be; set up a text file/s with the layer names in and have the program follow it until x(floor number) = floornoabsolute. The reason for this is I don't know enough yet to decipher any posts pertaining to Sequential numbering LISPs.
Is there a relatively simple way to tell the program to create a set of layers, lets say NLP x walls, where x starts at 1 and progresses sequentially until x= floornoabsolute?