(defun c:test ( / *error* MakeList key lst dc Make Models Model Year flag path blox)
(vl-load-com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ERROR HANDLER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun *error* ( msg ) ;;
(and dc (unload_dialog dc)) ;;
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") ;;
(princ (strcat "\n** Error: " msg " **"))) ;;
(princ) ;;
) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;PATH VARIABLE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq path "Y:\\bhull\\_Lispl3ox\\_Untestecl\\") ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BEGINNING OF LIST lst;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq lst (list nil "Pressure_Reducing_Regulator_w_External_Tap" "Pressure_Reducing_Regulator" "Gate_Valve_w_Bleed_Valve_Piston_Act" "Gate_Valve_w_Bleed_Valve"
"Flgd_Pressure_Reducing_Regulator" "Flgd_Gate_Valve_w_Bleed_Valve_Piston_Act" "Flgd_Gate_Valve_w_Bleed_Valve" "Flgd_Ball_Valve_w_Bleed_Valve" "Ball_Valve_w_Bleed_Valve")
Slide1$ (nth 1 lst)
Slide2$ (nth 2 lst)
Slide3$ (nth 3 lst)
Slide4$ (nth 4 lst)
Slide5$ (nth 5 lst)
Slide6$ (nth 6 lst)
Slide7$ (nth 7 lst)
Slide8$ (nth 8 lst)
Slide9$ (nth 9 lst)
Slide10$ (nth 10 lst)
);setq
(setq Data
'(
("Valves" . (("_ANGLE_VALVE" . ("Angle Valve" "Angle Control Valve" "Flanged Angle Valve" "Flanged Angle Control Valve"))
("_BACKPRESSURE_REGULATOR" . ("Backpressure Regulator" "Flanged Backpressure Regulator" "Backpressure Regulator w External Tap"))
("_BALL_VALVE" . ("CV with Hand Actuator" "Diaphragm Actuated CV" "Three Way Control Valve- HO"))
("_BLEED_VALVES" . ("Double Acting-Air to Close and Open" "Piston Operated Ball Valve" "Piston Operated Three-Way Valve" "Piston Operated Valve"))
("_BUTTERFLY_ON_OFF_VALVE" . ("Butterfly On-Off Valve" "Flanged Butterfly On-Off Valve" "Butterfly Valve" "Flanged Butterfly Valve" "Butterfly
Control Valve - HO" "Flanged Butterfly Control Valve - HO" "Butterfly Control Valve" "Flanged Butterfly Control Valve"))
("_CHECK_VALVE" . ("Angle Control Valve" "Three-Way Control Valve-HO" "Four-Way Solenoid Valve"))
("_DIAPHRAGM_AND_HAND_ACT_GV" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_FOUR_WAY_VALVES" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_GATE_VALVES" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_GLOBE_VALVE" . ("Globe Valve" "Globe Control Valve" "Flanged Globe Valve" "Flanged Globe Control Valve"))
("_MOTOR_OPERATED_VALVE" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_NEEDLE_VALVES" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_PLUG_VALVE" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_PRESSURE_REDUCING_REGULATOR" . ("Pressure Reducing Regulator" "Flanged Pressure Reducing Regulator" "Pressure Reducing Regulator w External
Tap"))
("_SOLENOID_VALVE" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_THREE_WAY_VALVE" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))
("_VALVES_withBLEED_VALVES" . ("Motor Operated Valve" "Two-Way Motor Operated Ball Valve"))))
("Instruments" . (("Local Panel" . ("_LOCAL_PANEL_MOUNTED_PROGRAMMABLE_LOGIC_CONTROL" "_local_panel_mounted_instrument"
"_local_panel_mounted_computer_function" "_local_mounted_programmable_logic_control" "_LOCAL_MOUNTED_INSTRUMENT" "_local_mounted_computer_function"
"_behind_local_panel_instrument"))
("Control Panel" . ("_control_panel_mounted_programmable_logic_control" "_control_panel_mounted_instr" "_control_panel_mounted_computer_function"
"_behind_control_panel_mounted_programmable_logic_control" "_behind_control_panel_instrument"))
("Shared Display" . ("_shared_display_with_instrument_bubble"))))
("Stamps" . (("Issued For:" . ("Flgd Angle Valve" "Flgd Four-Way Valve" "Flgd Three-Way Ball Valve" "Flgd Three-Way Valve"))
("Note:" . ("Flgd Backpressure Regulator" "Flgd Pressure Reducing Regulator" "Flgd Backpressure Regulator w External Tap" "Flgd Pressure Reducing
Regulator w External Tap"))
("Other" . ("Fldg Ball Type Control Valve" "Flgd Two Way Motor Operated Ball Vlv" "Flgd Piston Op Ball Valve"))
("Butterfly Valves" . ("Flgd Butterfly CV-HO" "Flgd Butterfly CV" "Flgd Butterfly On-Off Valve"))
("Motor Valves" . ("Flgd Motor Operated Ball Valve" "Flgd Motor Operated Valve" "Right Flgd Motor Operated Valve" "Left Flgd Motor Operated
Valve"))))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;END OF LIST lst;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BEGIN SUBFUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun MakeList ( key l )
(start_list key)
(mapcar (function add_list) l)
(end_list)
)
(defun slide ( key file )
(if (setq file (findfile file))
(progn
(start_image key)
(fill_image 0 0 (dimx_tile key) (dimy_tile key) 0)
(slide_image 1 1 (- (dimx_tile key) 2) (- (dimy_tile key) 2) file)
(end_image)
)
)
)
(defun my-block-files (path /) ;;
(setq lst ;;
(vl-directory-files path "*.dwg" 1)) ;;
)
(defun updateimage (sldname key)
(setq width (dimx_tile key))
(setq height (dimy_tile key))
(start_image key)
;(fill_image 1 1 width height 1)
(slide_image 1 1 width height sldname)
(end_image)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;END OF FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;BEGIN MAIN LOOP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(cond ( (<= (setq dc (load_dialog "Example.dcl")) 0) ;;
;;
(princ "\n** DCL File not Found **")) ;;
;;
( (not (new_dialog "test" dc)) ;;
;;
(princ "\n** Dialog could not be loaded **")) ;;
;;
(t
(MakeList "make" (mapcar (function car) Data))
(setq Make (atoi (set_tile "make" "0")))
(MakeList "model" (mapcar (function car) (cdar Data)))
(setq Model (atoi (set_tile "model" "0")))
(MakeList "year" (cdadar Data))
(setq Year (atoi (set_tile "year" "0")))
; (MakeList "blox" (my-block-files path))
(setq blox (my-block-files path))
(setq key "sld")
(slide "sld" (strcat path (nth (atoi (nth year blox)) lst) ".sld"))
(updateimage (nth year blox) key)
(action_tile "make" "(MakeList \"model\"
(mapcar (function car)
(setq Models (cdr (nth (setq Make (atoi $value)) Data)))))
(set_tile \"model\" \"0\")
(MakeList \"year\" (cdar Models))
(setq Year (atoi (set_tile \"year\" \"0\")))")
(action_tile "model" "(MakeList \"year\" (cdr (nth (setq Model (atoi $value)) Models)))
(setq Year (atoi (set_tile \"year\" \"0\")))")
(action_tile "year" "(slide \"sld\" (strcat path (nth (atoi $value) lst) \".sld\"))")
(setq flag (start_dialog) dc (unload_dialog dc))
(if (= 1 flag)
(progn
(updateimage (nth year blox) key)
(setq Selection (nth Make Data)
Make (car Selection)
Models (nth Model (cdr Selection))
Model (car Models)
Year (nth Year (cdr Models)))
(command "_insert" year pause "" "" pause))
(princ "\n*Cancel*"))))
(princ))
;;;;;;;end of lisp;;;;;;;;;;;
;;;;;;;;;;start of dcl;;;;;;;;;;;;;;;
lst : list_box { alignment = centered; fixed_width = true; width = 25; }
lst2 : list_box { alignment = centered; fixed_width = true; width = 40; }
test : dialog { label = "Dynamic Valve Selection"; spacer;
: row { spacer;
: lst { key = "make" ; label = "Class" ; } spacer;
: lst { key = "model"; label = "Type"; } spacer;
: lst2 { key = "year"; label = "Specification"; } spacer;
: boxed_column { label = "Preview";
: image { key = "sld"; height = 8; fixed_height = true;
width = 30; fixed_width = true; color = 0; aspect_ratio = 1;
is_enabled = true; is_tab_stop = false;
}
}
}
spacer;
ok_cancel;
}
There it is
Some of the code is useless, i'm aware, but have been trying so many different things to get this to work...nothing works