Thanks for the response guys. Let me see if I can explain it a bit better. The dcl file loads fine in the preview window whether the radio buttons are defaulted or not. The problem is when I run it from the lsp file. If I set the radio buttons to a default via (value = "1"; ) the lsp crashes. It will work with no defaults set try it... remember to set all the radios ! P.S. I haven't developed the "plan view" yet so try the elevation view.
;; save as swamp.dat
;;;Fan specifications
**make
*model
**MANUFACTURER1
*MODEL1
23.0,12.0,22.25,2.0,15.5,9.625,13.0,15.125,13.0,16.875,28.375,13.25,21.375,9.75,1.5,16.0,21.375,16.0
*MODEL2
41.5,19.75,45.125,2.5,25.0,19.0,25.875,31.5,26.0,33.625,57.75,26.25,40.625,17.75,1.5,31.125,36.0,31.125
**MANUFACTURER2
*MODEL2
23.0,12.0,22.25,2.0,15.5,9.625,13.0,15.125,13.0,16.875,28.375,13.25,21.375,9.75,1.5,16.0,21.375,16.0
*MODEL1
41.5,19.75,45.125,2.5,25.0,19.0,25.875,31.5,26.0,33.625,57.75,26.25,40.625,17.75,1.5,31.125,36.0,31.125
;;end of swamp.dat
//;; save as swamp.dcl
// logo dialog
logo
:text_part {
label = "Gators @ The Swamp ©2005";
alignment=centered;
is_bold=true;
}
centrifugal : dialog { //dialog name
label = "Centrifugal Fan Selection" ;
: row {
: boxed_radio_column {
label="Fan Desigantion";
: edit_box {key = "T"; label = "Tag:"; edit_width = 10;}
: edit_box {key = "C"; label = "CFM:"; edit_width = 10;}
}
: boxed_column {
label = "Fan Selection" ;
: popup_list {
label = "Select the Make:";
key = "K";
value = "0" ;
edit_width = 18;
}
: popup_list {
label = "Select the Model:";
key = "D";
value = "0" ;
edit_width = 18;
}
}
}
spacer_1;
: boxed_radio_row {
label = "Discharge";
: radio_button {label = "TH";key = "_TH";}
: radio_button {label = "TAD";key = "_TAD";}
: radio_button {label = "DB";key = "_DB";}
: radio_button {label = "BAD";key = "_BAD";}
: radio_button {label = "BH";key = "_BH";}
: radio_button {label = "BAU";key = "_BAU";}
: radio_button {label = "UB";key = "_UB";}
: radio_button {label = "TAU";key = "_TAU";}
} //end row
spacer_1;
: row {//start row
spacer_1;
: boxed_radio_column {
label="View";
: radio_button {label = "Plan";key = "P";}
: radio_button {label = "Elevation";key = "E";}
}
: boxed_radio_row {
label = "Motor Location";
: radio_button {label = "C";key = "_C";}
: radio_button {label = "W";key = "_W";}
: radio_button {label = "X";key = "_X";}
: radio_button {label = "Y";key = "_Y";}
: radio_button {label = "Z";key = "_Z";}
}
spacer_1;
: boxed_radio_column {//start row
label = "Rotation";
: radio_button {label = "Clockwise";key = "_CW";}
: radio_button {label = "CounterClockwise";key = "_CCW";}
}
}//end row
spacer_1;
ok_cancel ; //predefined OK/Cancel button
spacer_1;
logo;
}
//; end of swamp.dcl
;; save as swamp.lsp
(defun centrifugal (/ dcl_id makes models make model tag cfm name_file fp line char lst naut rotdis
disch view A B C D E F H J K L M N O P Q R S TT dlist ans pt1 pt2 pt3 pt4 pt5
pt6 pt7 pt8 pt9 pt10 pt11 pt12 pt13 pt14 pt15 pt16 pt17 cp disang r1 r2 r3 tsp1
tsp2 applic grp
)
;(init)
(load_utilities)
;;load the dialog
(setq dcl_id (load_dialog "swamp.dcl")
makes '("Manufacturer1" "Manufacturer2")
models '("Model1" "Model2")
tag "EF-"
cfm "VERIFY"
)
(if (not (new_dialog "centrifugal" dcl_id))
(exit)
)
;;setup the list box
(start_list "K")
(mapcar 'add_list makes)
(end_list)
(start_list "D")
(mapcar 'add_list models)
(end_list)
;;default rotation angle
(set_tile "C" cfm)
(set_tile "T" tag)
;;setup the Cancel button
(action_tile
"cancel"
"(done_dialog) (setq userclick nil)"
)
(action_tile "P" "(setq view \"P\")")
(action_tile "E" "(setq view \"E\")")
(action_tile "_W" "(setq motor \"W\")")
(action_tile "_X" "(setq motor \"X\")")
(action_tile "_C" "(setq motor \"C\")")
(action_tile "_Y" "(setq motor \"Y\")")
(action_tile "_Z" "(setq motor \"Z\")")
(action_tile "_CW" "(setq naut \"CW\")")
(action_tile "_CCW" "(setq naut \"CCW\")")
(action_tile "_TH" "(setq disch \"TH\")")
(action_tile "_TAD" "(setq disch \"TAD\")")
(action_tile "_DB" "(setq disch \"DB\")")
(action_tile "_BAD" "(setq disch \"BAD\")")
(action_tile "_TAU" "(setq disch \"TAU\")")
(action_tile "_UB" "(setq disch \"UB\")")
(action_tile "_BAU" "(setq disch \"BAU\")")
(action_tile "_BH" "(setq disch \"BH\")")
;;setup the OK button
(action_tile
"accept"
(strcat
"(progn (setq make (atof (get_tile \"K\"))
model (atof (get_tile \"D\"))
cfm (strcase(get_tile \"C\"))
tag (strcase(get_tile \"T\"))
)"
"(done_dialog) (setq userclick T))"
)
)
;;display the dialog
(start_dialog)
;;unload the dialog
(unload_dialog dcl_id)
;;now open file and get fan data
(cond
(userclick
(setq make (strcase
(strcat "**" (nth (fix make) makes))
)
model (strcase
(strcat "*" (nth (fix model) models))
)
)
;;now open file and get fan data
(setq name_file (findfile "swamp.dat"))
(cond
(name_file
(setq fp (open name_file "r"))
(while (setq line (read-line fp))
(setq char (substr line 1 2))
(cond
((= char ";"))
((= char "**")
(cond
((= make line)
(while (and (not lst)
(/= "**" (substr (setq line (read-line fp)) 1 2))
)
(setq char (substr line 1 1))
(cond ((= char ";"))
((= char "*")
(and (= model line) (setq lst (read-line fp)))
)
)
)
)
)
)
)
)
(close fp)
)
)
)
)
(cond (lst
;; make dlist all reals
(setq dlist (car
(mapcar ; repeat the function foreach item in the list
(function (lambda (n) (str2nums n ",")))
(list ; added this to make it a list
lst ; this returns the data as a string
)
)
)
)
(mapcar 'set
'(A B C D E F H J K L M N O P Q R S TT)
dlist
)
;;got data now draw the fan
(if (null (tblsearch "layer" "M-Equipment Detail"))
(equipment_layers)
)
(setq rotdis (strcat naut disch))
(cond ((= view "E")
(cond ((or (= rotdis "CWTH") (= rotdis "CCWBH"))
(setq disang 0)
)
((or (= rotdis "CWTAU") (= rotdis "CCWBAU"))
(setq disang (dtr 45.0))
)
((or (= rotdis "CWUB") (= rotdis "CCWUB"))
(setq disang (dtr 90.0))
)
((or (= rotdis "CWBAU") (= rotdis "CCWTAU"))
(setq disang (dtr 135.0))
)
((or (= rotdis "CCWTH") (= rotdis "CWBH"))
(setq disang (dtr 180.0))
)
((or (= rotdis "CCWTAD") (= rotdis "CWBAD"))
(setq disang (dtr 225.0))
)
((or (= rotdis "CCWDB") (= rotdis "CWDB"))
(setq disang (dtr 270.0))
)
((or (= rotdis "CWTAD") (= rotdis "CCWBAD"))
(setq disang (dtr 315.0))
)
)
(cond
((and (not Q) (<= H 15.0)) (setq Q 2.0))
((and (not Q) (> H 15.0)) (setq Q 4.0))
)
(setvar "osmode" 2)
(setq pt1 (upoint 1 "" "Select midpoint of curb" nil nil))
(setvar "osmode" 0)
(setq cp (polar pt1 (dtr 90.0) J)
R1 (/ (+ (- P Q) (* J 0.6)) 2.0)
R2 (/ (+ (- O P) (* J 0.6)) 2.0)
R3 (/ (+ (- O P) N) 2.0)
pt2 (polar pt1 0 (/ L 2.0))
pt3 (polar pt1 0 (/ TT 2.0))
pt4 (polar pt3 (dtr 180.0) (distance pt3 pt2))
pt11 (polar pt2 (dtr 180.0) L)
pt10 (polar pt1 (dtr 180.0) (/ TT 2.0))
pt9 (polar pt11 0 (distance pt4 pt2))
pt5 (polar pt4
(dtr 90.0)
(- C (/ (distance pt9 pt4) 3.0))
)
pt6 (polar pt5
(dtr 135.0)
(* (/ (distance pt9 pt4) 3.0) (cosecant (dtr 45.0)))
)
pt7 (polar pt6 (dtr 180.0) (/ (distance pt9 pt4) 3.0))
pt8 (polar pt7
(dtr 225.0)
(* (/ (distance pt9 pt4) 3.0) (cosecant (dtr 45.0)))
)
)
(command "layer" "s" "M-Equipment Detail" "")
(command "linetype" "s" "hidden" "")
(command "circle" cp "d" H)
(setq grp (ssget "L"))
(setq tsp1 (polar cp (dtr 90.0) (/ H 2))
tsp2 (polar tsp1 (dtr 270.0) H)
)
(command "pline"
tsp1
"a"
"r"
(/ H 4.0)
cp
tsp2
""
)
(harvest)
(command "linetype" "s" "bylayer" "")
;; fan below
(if (= "CCW" (substr rotdis 1 3))
(setq factor -1.0)
(setq factor 1.0)
)
(setq pt15 (polar cp (+ disang (* factor (dtr 90.0))) N)
pt14 (polar pt15 disang P)
pt13 (polar pt14 (+ disang (* factor (dtr 270.0))) K)
pt12 (polar pt13 (+ disang (* factor (dtr 180.0))) Q)
pt16 (polar cp (+ disang (* factor (dtr 180.0))) (- O P))
pt17 (polar cp (+ disang (* factor (dtr 270.0))) (* J 0.6))
)
(command "layer" "s" "M-Equipment" "")
(if (= "CCW" (substr rotdis 1 3))
(command "pline" pt14 pt13 pt12 "a" "r" R1 pt17 "r" R2 pt16 "r" R3 pt15 "l" pt14
""
)
(command "pline" pt13 pt14 pt15 "a" "r" R3 pt16 "r" R2 pt17 "r" R1 pt12 "l" pt13
""
)
)
(harvest)
(command "layer" "s" "M-Equipment Detail" "")
(command "circle" cp "d" 1.5)
(harvest)
(command "pline" pt2 pt4 pt5 pt6 pt7 pt8 pt9 pt11 "c")
(harvest)
) ; end elevation view
(T
(vl-load-com)
(setq applic (vlax-get-acad-object))
(vla-eval
applic
(strcat
"MsgBox \"Plan view not yet available...\"" ", " "vbInformation" ", "
"\"Swamp\""
)
)
)
)
(setq tp2
(upoint 1 "" "Select BOTTOM LEFT for text location" nil nil)
)
(command "layer" "S" "M-Equipment Text" "")
(command "-insert"
"Equip Tag"
tp2
"25"
""
"0"
tag
(strcat (rtos H 5 2) "\"%%C Inlet")
(strcat (rtos K 5 2)
"\" x "
(rtos F 5 2)
"\" Disch"
" ("
cfm
"-CFM)"
)
(strcat "Model: " (substr model 2) " " rotdis)
(strcat "Motor Position: \"" motor "\"")
)
(harvest)
(if grp
;; we can get rid of this when plan view is developed
(command "-group" "c" "*" "" grp "")
)
)
(T
(vl-load-com)
(setq applic (vlax-get-acad-object))
(vla-eval
applic
(strcat
"MsgBox \"Fan Data was not found Make and/or Model not listed...\"" ", "
"vbInformation" ", " "\"Swamp\""
)
)
)
)
;(reset)
(princ)
)
(defun load_utilities ()
(defun equipment_layers ()
(command "layer" "m" "M-Equipment" "c" "1" "" "lw" ".80" "" ""
)
(command "layer" "m" "M-Equipment Text" "c" "240" "" "lw" ".00" "" ""
)
(command "layer" "m" "M-Equipment Detail" "c" "30" "" "lw" "0" "" ""
)
)
(defun upoint (bit kwd msg def bpt / inp)
(if def
(setq pts (strcat (rtos (car def))
","
(rtos (cadr def))
(if (and (caddr def) (= 0 (getvar "FLATLAND")))
(strcat "," (rtos (caddr def)))
""
)
)
msg (strcat " \n" msg " <" pts ">: ")
bit (- bit (boole 1 bit 1))
)
(if (= " " (substr msg (strlen msg) 1))
(setq msg (strcat "\n" msg (substr msg 1 (1- (strlen msg))) ": "))
(setq msg (strcat "\n" msg ": "))
)
)
(initget bit kwd)
(setq inp
(if bpt
(getpoint msg bpt)
(getpoint msg)
)
)
(if inp
inp
def
)
)
(defun harvest () ; these are global set local @ main routine
(setq grp (ssadd (entlast) grp))
(princ)
)
(defun str2nums (aStr delim / strList pos)
(while (setq pos (vl-string-search delim aStr 0))
(setq strList (cons (substr aStr 1 POS) strList)
aStr (substr aStr (+ pos 2))
)
)
(reverse (cons aStr strList))
(mapcar 'atof (reverse (cons aStr strList)))
)
)
;; end of swamp.lsp