@ArchD wrote:
....
I've attached it so you can shame me on how poor my coding ability is.
I don't know about the failure [don't have C3D], but since you asked, I'll point out two significant improvements you can make.
This is the perfect situation for using a (cond) function instead of a series of (if) functions. As you have it, the routine has to check the *ans* value against every possible option individually, no matter which one was chosen, and even after it has already found and processed the right one. With (cond), it checks only until it finds the satisfied condition, then does what's asked for about that, and doesn't bother looking at any of the others, but jumps right to the end of the (cond). It also eliminates all those (progn) functions that are needed within an (if) function to wrap multiple operations into a single 'then' expression.
And, a single (command) function can contain any number of command operations, so you don't need to wrap each one up and then start a new (command) function for the next one.
An excerpt [untested]:
;;; Execute offsets based on user selection
(cond
((= *ans* "type-A")
; if this returns T, do the following and skip all other conditions;
; if it returns nil, move to the next conditional test
(command
"OFFSETFEATURE" "0.583333" UserSel OSSide "0" ""
"-layer" "M" "P-CURB-FL" "C" "151" "" "PS" "1 - Fine" "" ""
"chprop" "L" "" "LA" "P-CURB-FL" ""
"OFFSETFEATURE" "0.593333" UserSel OSSide "0.166667" ""
"-layer" "M" "P-CURB-FOC-TYPE A" "C" "7" "" "PS" "1 - Fine" "" ""
"chprop" "L" "" "LA" "P-CURB-FOC-TYPE A" ""
"OFFSETFEATURE" "1.33333" UserSel OSSide "0.4166667" ""
"-layer" "M" "P-CURB-BOC" "C" "3" "" "PS" "1 - Fine" "" ""
"chprop" "L" "" "LA" "P-CURB-BOC" ""
); end command
(setvar "CLAYER" CURLay)
); end type-A condition
((= *ans* "type-B")
(command
"OFFSETFEATURE" "0.01" UserSel OSSide "0.1666667" ""
....
....
"chprop" "L" "" "LA" "P-CURB-BOC" ""
); end command
(setvar "CLAYER" CURLay)
); end Shoulder condition
((= *ans* "Valley")
(command
"OFFSETFEATURE" "1.16667" UserSel OSSide "-0.104167" ""
"-layer" "M" "P-CURB-FL-VALLEY" "C" "151" "" "PS" "1 - Fine" "" ""
"chprop" "L" "" "LA" "P-CURB-FL-VALLEY" ""
"OFFSETFEATURE" "3" UserSel OSSide "0" ""
"-layer" "M" "P-CURB-EOP" "C" "2" "" "PS" "2 - Very Thin" "" ""
"chprop" "L" "" "LA" "P-CURB-EOP" ""
); end command
(setvar "CLAYER" CURLay)
); end Valley condition
); end cond
(princ)
)
Kent Cooper, AIA