...to reprogram a bit of code.
I wrote a small program about 11 years ago (for AutoCAD R14), and at that time with my knowledge of AutoLisp that I had. I recently dug this code out, reevaluated it and made it work for AutoCAD 2010. Knowing what I know now, I have a feeling this code is a bit redundant and I'm looking for a way to shorten it or find a different solution.
The function does the following:
Starting with two lists of different length, it cycles through each one simultaneously pairing the atoms of each list. When one list comes to the end, it starts over from the beginning. The same with the other list. For example, the first list could have any number of atoms from 1 to the maximal allowed. The second list is an list of points which are fixed at 11.
Added to the program is a counter that exits the program once so many paired items have gone through which the user sets at the beginning of the program.
The counter is a WHILE statement counting down the total number of points and the cycling is done with IF statements. At the time I wrote the program I didn't think COND could be an option because it would exit the program during the 11 point cycle. The program needs to continuously step through the 11 point cycle and has to decide if the point is to be carried out or not. If the counter is exhausted, then it stops at this point and exits the program.
I've listed the basic structure of the code to read through, but took out what it does to each point in the PROGN statement because it's not relevant. Trying to run it would fail.
The main question I have is if I could somehow get rid of all the IF statements and substitute them with something else.
If my question is not clear, just ask I'll try to explain it again. I look forward to hearing from you.
(setq num_pl 0)
(setq num 100)
(while (< num_pl num)
(if (< num_pl num)
(progn
(...pt01)
)
)
(command "_.change" el "" "_p" "_c" col_pl "")
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt02)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt03)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt04)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt05)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt06)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt07)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt08)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt09)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt10)
)
)
(setq num_pl (1+ num_pl))
(if (< num_pl num)
(progn
(...pt11)
)
)
)