Guspar Posted June 8, 2023 Posted June 8, 2023 Hi everyone, After much research and command list digging, I thought I would reach out for some help. Any input would be most appreciated! I have a AutoLisp command that I trying to write. The end goal is to run a command that would continue to select the next option until no further options are available and then end. For a short description we use a custom command that dimensions blocks, once the command is entered you are asked to select an option. After option is selected it ask for location for the dimension, once picked (or entered manually) the selection process ends. The block may contain one or all of the example options so If more than one it requires running the command again on the same block which seems entirely unnecessary, but unfortunately it was how it was designed to function. Command line example CUSTOM Enter an option [A B C D E 1 2 3 4 5]: A Enter Location for dimension: I believe I've narrowed a possible option to accomplish this, but I am still fairly new to AutoLisp. Here is the start of "MYCOMMAND" that would define all possible variables that could arise as options and then call on them to manipulate the CUSTOM command. I mainly need direction on if I should use some kind of loop and while statement to continue COMMAND and select the next options or possibly put the options in a list to run sequential if statements? Open to any suggestions or "homework" references. THANK YOU! (defun c:MYCOMMAND (A B C D E 1 2 3 4 5 WIDTH SIDE ELEVATION) ;OTHER VAR NEEDED FOR CONDITIONAL STATEMENTS LATER (setq WIDTH (getreal "Enter Block Width: ")) ;BLOCKS CAN BE VERY LONG, VARIOUS SIZES. ENTERING THIS UPFRONT WOULD HELP CALC A DIM OFFSET LATER (setq SIDE (getreal "Enter Desired Side For Dimensions, L or R: ")) ;PRE-DETERMINE LOCATION OF DIM (setq ELEVATION (getreal "Enter Elevation: ")) ;DRAW DIM ON ELEVATION, OFTEN DIFFERENT THAN GLOBAL ELEVATION (command "CUSTOM") Quote
mhupp Posted June 9, 2023 Posted June 9, 2023 Sounds like you need to use the while function. Depending on how you want it to act either need to wrap the whole lisp or just part of it. Example 1 repeats part of the lisp so if you want to pick multiple spots with a single option. Command line example CUSTOM Enter an option [A B C D E 1 2 3 4 5]: A Enter Location for dimension: Enter Location for dimension: ... (Will continue until you don't pick a point) Example 2 repeats the whole lisp so you can pick multiple spots but will ask for an option each time. Command line example CUSTOM Enter an option [A B C D E 1 2 3 4 5]: A Enter Location for dimension: CUSTOM Enter an option [A B C D E 1 2 3 4 5]: A Enter Location for dimension: CUSTOM Enter an option [A B C D E 1 2 3 4 5]: D Enter Location for dimension: CUSTOM Enter an option [A B C D E 1 2 3 4 5]: 5 Enter Location for dimension: (Will continue until you don't pick option) For your variables a little advice. ;get dist allows you to either use your mouse picking two points for a distance ;or inputing a distance and if your in the US you can input things like 12'6" as well. (setq WIDTH (getdist "Enter Block Width: ")) ;this will only accept left or right as an input. you can make it as simple and typeing L and hitting enter it will then be "Left" (initget "Left Right") (setq SIDE (cond ((getkword "\n"Enter Desired Side For Dimensions[<Left> or Right]: ")) ("L") ;hitting enter here will default to left. ) ) (C:CUSTOM) ;this is how you call another lisp but all those varables should be declaired in the "custom" lisp. Quote
BIGAL Posted June 10, 2023 Posted June 10, 2023 Not sure what your doing a dwg would help. This allows you to select multiple options. (if (not AH:Toggs)(load "Multiple toggles.lsp")) (setq lst '("A B C D" "A" "B" "C" "D" "1" "2")) (setq ans (reverse (ah:toggs lst))) returns ("1" "0" "0" "1" "0" "1") the "1" matches the toggle is on. You can then create the variables with a yes no style of answers using say multiple If's. More advanced is to make variables from the lst as names and fill in yes or No. Multi toggles.lsp 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.