Author Topic: Routine not working, please help.  (Read 4415 times)

0 Members and 2 Guests are viewing this topic.

Bhull1985

  • Guest
Routine not working, please help.
« on: September 26, 2013, 11:12:27 AM »
I am having a tremendous amount of trouble having a simple slide image appearing in my dcl
I've tried everything I can think of and have not been able to get the image to preview or show at all
Even though I've got a direct path to it
and have seen this SAME CODE work in another routine, which is successful in having the slides preview.

I'm not even going to worry about the dynamic blocks portion that will be included into this lisp at some point, just right now I want my list_boxes to populate correctly as well as having the slide preview update with each selection
A challenge for a guru surely, but this is impossible for me. I've spent over 20 hours this week and haven't had one slide appear.
If someone would be so kind as to show me what i'm doing wrong I would GREATLY appreciate the chance to be able to MOVE FORWARD WITH THIS.
« Last Edit: October 01, 2013, 09:52:57 AM by Bhull1985 »

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Routine not working, please help.
« Reply #1 on: September 26, 2013, 11:32:11 AM »
I am no guru but to I can help in getting your code to viewed easier by the other members.

Modify your post and paste your code between code tags
[ code] Paste your Code here [ /code]

You can get the code tags by hitting the above button.   Post both lisp and your dcl code.


I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #2 on: September 26, 2013, 11:38:02 AM »
Code: [Select]

(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

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Routine not working, please help.
« Reply #3 on: September 26, 2013, 11:42:59 AM »
Okay couple of other suggestion.  For when I am debugging code, I sprinkle a couple of watches to local variables throughout the code and once the code has finished running,  I check to see the results to see if it meets my expectations. 

Sorry I got interrupted. 
First Are you sung vlide editor?  IF so you, you would highlight the variable > right click and select ADD WATCH.

« Last Edit: September 26, 2013, 12:02:43 PM by Krushert »
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #4 on: September 26, 2013, 11:52:26 AM »
Yes I've been using the vlide quite a lot but I need someone who can tell me what i'm doing wrong in the code
thought I do appreciate your attentions, I need to find out what i'm doing incorrectly else i'll never learn the stuff nor have my slide preview

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Routine not working, please help.
« Reply #5 on: September 26, 2013, 11:54:04 AM »
Got it to work, see attached.
Note that I commented out some code.
There is a problem with this
Code: [Select]
(updateimage (nth year blox) key)probably not creating the proper file name.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #6 on: September 26, 2013, 01:13:59 PM »
You are the MAN!
Thanks so much, I'm going to look now..

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #7 on: September 26, 2013, 01:26:31 PM »
So In my action tile for "year" I should save the value of the tile and pass that back to the update image function?
That's where I believe the (atoi $value) would be necessary except that I keep getting a stringp error when it's passed back and attempts to fill the slide image using the "file" variable
I'm wondering how I can have the 3rd listbox pass it's value as a string back to the slide tile so that it can wipe and re-fill the slide tile each time an item in the 3rd list_box is selected.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Routine not working, please help.
« Reply #8 on: September 26, 2013, 02:35:08 PM »
The $value returned for year will be an index of the following:
("Angle Valve" "Angle Control Valve" "Flanged Angle Valve" "Flanged Angle Control Valve")
So your intent was to use a path :
"Y:\\bhull\\_Lispl3ox\\_Untestecl\\" plus "Angle Valve" plus ".sld"

Action "(slide \"sld\" (strcat path (nth (atoi $value) lst) \".sld\"))"
(atoi $value) -> 0
(nth 0 lst) ->  Filename.dwg
(strcat path (nth 0 lst) ".sld")  -> Filename.dwg.sld
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Routine not working, please help.
« Reply #9 on: September 26, 2013, 03:26:09 PM »
So you need to create a list of sld files or strip off the ".dwg" if you have slides with names to match.

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #10 on: September 26, 2013, 05:01:50 PM »
Thank you CAB
Many 'kudos' for helping me with this, if only I could give them here :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Routine not working, please help.
« Reply #11 on: September 26, 2013, 11:25:51 PM »
Glad to help.
I'm off for the week end but if you get stuck someone will step in. 8)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #12 on: October 01, 2013, 01:24:51 PM »
Hi, I haven't quite been able to get this working properly. I've been attempting to add a lot of code to a working routine by lee mac
There's this:
Code: [Select]
** Error: bad argument type: consp nil **That occurs when an item in the 2nd list box is the first user selection
And there's a problem stopping the slide preview which is supposed to operate off the final list box's selection and display a .sld preview


I just do not know how to construct a list of the slides that would make the value of the last selection in the 3rd list box display the correct slide, even though I do have the slides made and in a folder. The $value for the variable "year" (still from Lee's variable choices) will return an integer that will supply the (nth) function and pull from a list of slides, but there are over 100 slides and the $value variable will just be 1-10 because ten is the max amount of choices from any "model"(which populates the list that the user will select the slide (and later, block) from) and it's resultant list and 3rd list_box choices "year". Thusly ...i'm fearing it would only be able to return up to 10 slides from my slide list which should have over 100.
This is the issue that needs to be resolved with this routine if anyone has a suggestion please inform
Code: [Select]
  (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))

;(set_tile "sld" (nth Year lst))

(setq key "sld")
(slide "sld" (strcat "Ball_Valve_w_Bleed_Valve" ;|(strcat path (nth (atoi (nth year blox)) lst)|; ".sld"))



           (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" "(setq sld (atoi $value))(updateimage year sld)")





           (setq flag (start_dialog) dc (unload_dialog dc))

           (if (= 1 flag)
             (progn
(updateimage (nth year blox) sld)
               (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))

         

and the data list
Code: [Select]
(setq Data

     '(

       ("Valves"      . (("Angle Valves"     . ("Angle Valve" "Angle Control Valve" "Flanged Angle Valve" "Flanged Angle Control Valve"))
                          ("Backpressure Regulators"     . ("Backpressure Regulator" "Flanged Backpressure Regulator" "Backpressure Regulator w External Tap"))
                          ("Ball Valves"     . ("Two-Way Motor Operated Ball Valve" "Double Acting Piston Valve - Air Operated" "Piston Operated Ball Valve" "Flanged Motor Operated Ball Valve" "Flanged Piston Operated Ball Valve"

"Flanged Ball Type Control Valve" "Flanged Double Acting Piston Valve - Air Operated" "Flanged Ball Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Three-Way Ball Valve"))
                          ("Bleed Valves"     . ("Ball Valve w Bleed Valve" "Gate Valve w Bleed Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve and Piston Actuator" "Gate

Valve w Bleed Valve and Piston Actuator"))
                          ("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 Valves"       . ("Check Valve" "Flanged Check Valve"))
                          ("Dia and Hand Act Control Valves"       . ("Control Valve w Hand Actuator" "Flanged Control Valve w Hand Actuator" "Diaphragm Actuated Control Valve" "Flanged Diaphragm Actuated Control Valve"))
                          ("Four Way Valves"       . ("Four Way Valve" "Flanged Four Way Valve"))
                          ("Gate Valves"       . ("Gate Valve" "Flanged Gate Valve" "Right Flanged Gate Valve" "Left Flanged Gate Valve" "Piston Operated Gate Valve" "Flanged Piston Operated Gate Valve"))
                          ("Globe Valves"       . ("Globe Valve" "Flanged Globe Valve" "Globe Control Valve" "Flanged Globe Control Valve"))
                          ("Motor Operated Valves"       . ("Motor Operated Valve" "Flanged Motor Operated Valve" "Two-Way Motor Operated Ball Valve" "Flanged Motor Operated Ball Valve" "Right Flanged Motor Operated Valve" "Left Flanged

Motor Operated Valve"))
                          ("Needle Valves"       . ("Needle Valve" "Small Needle Valve" "Flanged Needle Valve"))
                          ("Plug Valves"       . ("Plug Valve" "Flanged Plug Valve"))
                          ("Pressure Reducing Regulator"       . ("Pressure Reducing Regulator" "Flanged Pressure Reducing Regulator" "Pressure Reducing Regulator w External Tap"))
                          ("Solenoid Valves"       . ("Two-Way Solenoid Valve" "Three-Way Solenoid Valve" "Four-Way Solenoid Valve" "Three-Way Solenoid Valve w Manual Reset" "Flanged Three-Way Solenoid Valve" "Flanged Three-Way Solenoid

Valve w Manual Reset" "Flanged Two-Way Solenoid Valve"))
                          ("Three Way Valves"       . ("Three Way Valve" "Flanged Three Way Valve" "Three Way Control Valve - HO" "Piston Operated Three Way Valve" "Pilot Valve w Manual Reset" "Flanged Pilot Valve w Manual Reset"

"Flanged Three Way Control Valve - HO" "Flanged Piston Operated Three-Way Valve"))
  ("Misc Valves"       . ("Rotary Valve" "Diaphragm 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 Instrument" "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"))
                          ))
      )
  )
« Last Edit: October 01, 2013, 01:42:03 PM by Bhull1985 »

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #13 on: October 01, 2013, 01:41:46 PM »
Would I need to wrap the slide variable setq in a conditional statement asking what "model" is?
Something like
(cond
(= model "Angle Valve")(setq lst "Angle Valve Vis1" "Angle Valve Vis2" "Angle Valve Vis3")
(= model "Backpressure Regulators")(setq lst "Backpressure Regulator Vis1" "Backpress Vis2....etc?

I will try it !

Bhull1985

  • Guest
Re: Routine not working, please help.
« Reply #14 on: October 01, 2013, 02:48:56 PM »
I feel like I am getting close
But I am getting a fixnump error
and am being pulled off onto some client work
Code: [Select]
(defun c:test ( / *error* MakeList key lst dc Make Models Model Year flag path file)
(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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (cond
( (= model "Angle Valves")
(setq lst (list nil "Angle Valve" "Angle Control Valve" "Flanged Angle Valve" "Flanged Angle Control Valve")         
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
File$ (nth 4 lst)
);setq
);cond
( (= model "Backpressure Regulators")
(setq lst (list nil "Backpressure Regulator" "Flanged Backpressure Regulator" "Backpressure Regulator w External Tap")
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
);setq
);cond

( (= model "Ball Valves")
(setq lst (list nil "Two-Way Motor Operated Ball Valve" "Double Acting Piston Valve - Air Operated" "Piston Operated Ball Valve" "Flanged Motor Operated Ball Valve" "Flanged Piston Operated Ball Valve" "Flanged Ball Type Control

Valve" "Flanged Double Acting Piston Valve - Air Operated" "Flanged Ball Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Three-Way Ball Valve")
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
File$ (nth 4 lst)
File$ (nth 5 lst)
File$ (nth 6 lst)
File$ (nth 7 lst)
          File$ (nth 8 lst)
          File$ (nth 9 lst)
          File$ (nth 10 lst)
);setq
);cond
( (= model "Bleed Valves")
(setq lst (list nil "Ball Valve w Bleed Valve" "Gate Valve w Bleed Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve and Piston Actuator" "Gate Valve w Bleed Valve and

Piston Actuator")
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
File$ (nth 4 lst)
File$ (nth 5 lst)
File$ (nth 6 lst)
);setq
);cond
( (= model "Butterfly On-Off Valve")
(setq lst (list nil "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")
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
File$ (nth 4 lst)
File$ (nth 5 lst)
File$ (nth 6 lst)
File$ (nth 7 lst)
          File$ (nth 8 lst)
);setq
);cond
( (= model "Check Valves")
(setq lst (list nil "Check Valve" "Flanged Check Valve")
File$ (nth 1 lst)
File$ (nth 2 lst)
);setq
);cond
( (= model "Dia and Hand Act Control Valves")
(setq lst (list nil "Control Valve w Hand Actuator" "Flanged Control Valve w Hand Actuator" "Diaphragm Actuated Control Valve" "Flanged Diaphragm Actuated Control Valve")
File$ (nth 1 lst)
File$ (nth 2 lst)
File$ (nth 3 lst)
File$ (nth 4 lst)
);setq
);cond
( (= model "Four Way Valves")
(setq lst (list nil "Four Way Valve" "Flanged Four Way Valve")
File$ (nth 1 lst)
File$ (nth 2 lst)
);setq
);cond
( (= model "Gate Valves")
(setq lst (list nil "Gate Valve" "Flanged Gate Valve" "Right Flanged Gate Valve" "Left Flanged Gate Valve" "Piston Operated Gate Valve" "Flanged Piston Operated Gate Valve")
        File$ (nth 1 lst)
        File$ (nth 2 lst)
        File$ (nth 3 lst)
        File$ (nth 4 lst)
        File$ (nth 5 lst)
        File$ (nth 6 lst)
   );setq
);cond
);cond


  (setq Data

     '(

       ("Valves"      . (("Angle Valves"     . ("Angle Valve" "Angle Control Valve" "Flanged Angle Valve" "Flanged Angle Control Valve"))
                          ("Backpressure Regulators"     . ("Backpressure Regulator" "Flanged Backpressure Regulator" "Backpressure Regulator w External Tap"))
                          ("Ball Valves"     . ("Two-Way Motor Operated Ball Valve" "Double Acting Piston Valve - Air Operated" "Piston Operated Ball Valve" "Flanged Motor Operated Ball Valve" "Flanged Piston Operated Ball Valve"

"Flanged Ball Type Control Valve" "Flanged Double Acting Piston Valve - Air Operated" "Flanged Ball Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Three-Way Ball Valve"))
                          ("Bleed Valves"     . ("Ball Valve w Bleed Valve" "Gate Valve w Bleed Valve" "Flanged Ball Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve" "Flanged Gate Valve w Bleed Valve and Piston Actuator" "Gate

Valve w Bleed Valve and Piston Actuator"))
                          ("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 Valves"       . ("Check Valve" "Flanged Check Valve"))
                          ("Dia and Hand Act Control Valves"       . ("Control Valve w Hand Actuator" "Flanged Control Valve w Hand Actuator" "Diaphragm Actuated Control Valve" "Flanged Diaphragm Actuated Control Valve"))
                          ("Four Way Valves"       . ("Four Way Valve" "Flanged Four Way Valve"))
                          ("Gate Valves"       . ("Gate Valve" "Flanged Gate Valve" "Right Flanged Gate Valve" "Left Flanged Gate Valve" "Piston Operated Gate Valve" "Flanged Piston Operated Gate Valve"))
                          ("Globe Valves"       . ("Globe Valve" "Flanged Globe Valve" "Globe Control Valve" "Flanged Globe Control Valve"))
                          ("Motor Operated Valves"       . ("Motor Operated Valve" "Flanged Motor Operated Valve" "Two-Way Motor Operated Ball Valve" "Flanged Motor Operated Ball Valve" "Right Flanged Motor Operated Valve" "Left Flanged

Motor Operated Valve"))
                          ("Needle Valves"       . ("Needle Valve" "Small Needle Valve" "Flanged Needle Valve"))
                          ("Plug Valves"       . ("Plug Valve" "Flanged Plug Valve"))
                          ("Pressure Reducing Regulator"       . ("Pressure Reducing Regulator" "Flanged Pressure Reducing Regulator" "Pressure Reducing Regulator w External Tap"))
                          ("Solenoid Valves"       . ("Two-Way Solenoid Valve" "Three-Way Solenoid Valve" "Four-Way Solenoid Valve" "Three-Way Solenoid Valve w Manual Reset" "Flanged Three-Way Solenoid Valve" "Flanged Three-Way Solenoid

Valve w Manual Reset" "Flanged Two-Way Solenoid Valve"))
                          ("Three Way Valves"       . ("Three Way Valve" "Flanged Three Way Valve" "Three Way Control Valve - HO" "Piston Operated Three Way Valve" "Pilot Valve w Manual Reset" "Flanged Pilot Valve w Manual Reset"

"Flanged Three Way Control Valve - HO" "Flanged Piston Operated Three-Way Valve"))
  ("Misc Valves"       . ("Rotary Valve" "Diaphragm 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 Instrument" "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"))
                          ))
      )
  )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 (file key)
(setq width (dimx_tile key))
(setq height (dimy_tile key))
(start_image key)
  (fill_image 0 0 (dimx_tile key) (dimy_tile key) -15); and change to your image name
(slide_image 1 1 width height file)
(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))

;(set_tile "sld" (nth Year lst))

(setq key "sld")
(slide "sld" (vl-filename-base (strcat path (nth (itoa $value) lst) ".sld")))



           (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" "(setq file (atoi $value))(updateimage year file)")





           (setq flag (start_dialog) dc (unload_dialog dc))

           (if (= 1 flag)
             (progn
(updateimage (nth year blox) sld)
               (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))