Author Topic: Need Help on Lisp & DCL  (Read 6757 times)

0 Members and 1 Guest are viewing this topic.

laison

  • Guest
Need Help on Lisp & DCL
« on: October 29, 2010, 07:28:50 PM »
I have this lisp & dcl file that I want to modify. I want to know if it has to be totally redone are that it can be used.

What I want to do is have the lisp file pull up this dcl file. When selecting the image it would trigger a selected script file that will insert a string or an assembly of valves are whatever user has selected.

I have created about 20 different scripts.   I also have the slides and slide library along with the text file.

Thank you



LISP FILE:

Code: [Select]
;;PASSEM.LSP Written by: UD
(defun C:PASSEM( / P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13
                               #TOP #BOT A1 D1 D2 S1 E1 E2)
  (setq Dat (load_dialog (strcat #MENUDIR "ASSEMBLY.DCL")))
  (if (not (new_dialog "ASM01" Dat)) (exit))
  (setq H (dimy_tile "I01"))
  (setq W (dimx_tile "I01"))
  
  (setq CNT 0)
  (repeat 30
    (setq CNT (+ CNT 1))
    (if (< CNT 10)
       (start_image (strcat "I0" (itoa CNT)))
       (start_image (strcat "I" (itoa CNT)))
    )
    (if (< CNT 10)
      (slide_image 0 0 W H (strcat #MENUDIR "ASM(ASM0" (itoa CNT) ")"))
      (slide_image 0 0 W H (strcat #MENUDIR "ASM(ASM" (itoa CNT) ")"))
    )
    (end_image)
  )



;;  (mode_tile "I16" 1)
  (mode_tile "accept" 1)
  (action_tile "accept" "(done_dialog 1)")
  (action_tile "cancel" "(done_dialog 0)")
  (setq Ok (start_dialog))
  (unload_dialog Dat)
  (if (= OK 1)
    (assembly ASM)
  )
  (princ)
)
  


DCL FILE:


Code: [Select]
ASM01 : dialog {
    value = "Select Piping Assembly";
    spacer;
    : column {
        fixed_width = true;
        fixed_height = true;
        width = 120;
        height = 34;
        aspect_ratio = 1.0;
        : row {
            : image_button {
                key = "I01";
                color = 250;
                action = "(setq ASM \"ASSEM01\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Std. Flanged Pair Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I02";
                color = 250;
                action = "(setq ASM \"ASSEM02\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Flanged Gate Valve Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I03";
                color = 250;
                action = "(setq ASM \"ASSEM03\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Flanged Ball Valve Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I04";
                color = 250;
                action = "(setq ASM \"ASSEM04\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Flanged Check Valve Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I05";
                color = 250;
                action = "(setq ASM \"ASSEM05\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Flanged Plug Valve Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I06";
                color = 250;
                action = "(setq ASM \"ASSEM06\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Flanged Globe Valve Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
        }
        : row {
            : image_button {
                key = "I07";
                color = 250;
                action = "(setq ASM \"ASSEM07\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Std. Flange & Blind Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I08";
                color = 250;
                action = "(setq ASM \"ASSEM08\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Common SWxSC Vent/drain Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I09";
                color = 250;
                action = "(setq ASM \"ASSEM09\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Gasket and RFWN Flange Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I10";
                color = 250;
                action = "(setq ASM \"ASSEM10\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Weldolet, RFWN Flange and Gasket Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I11";
                color = 250;
                action = "(setq ASM \"ASSEM11\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Gasket, WN Flange, Pipe, WN Flange, Gasket, Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I12";
                color = 250;
                action = "(setq ASM \"ASSEM12\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Gasket, WN Flange, Pipe, Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
        }
        : row {
            : image_button {
                key = "I13";
                color = 250;
                action = "(setq ASM \"ASSEM13\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Gasket, Slip-on Flange, Pipe, Slip-on Flange, Gasket, Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I14";
                color = 250;
                action = "(setq ASM \"ASSEM14\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Gasket, Slip-on Flange, Pipe, Assembly\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I15";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I16";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I17";
                color = 250;
                action = "(setq ASM \"ASSEM17\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Common Vent/Drain Assembly, Threaded\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I18";
                color = 250;
                action = "(setq ASM \"ASSEM18\") (mode_tile \"accept\" 0) (set_tile \"AEC\" \"Common Vent/Drain Assembly, Threaded, For Small Bore Piping\")";
                horizontal_margin = none;
                vertical_margin = none;
            }
        }
        : row {
            : image_button {
                key = "I19";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I20";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I21";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I22";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I23";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I24";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
          }
        : row {
            : image_button {
                key = "I25";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I26";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I27";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I28";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I29";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
            : image_button {
                key = "I30";
                color = 250;
                horizontal_margin = none;
                vertical_margin = none;
            }
          }
        }
        : text {
          label = "                      ";
          key = "AEC";
    }
    ok_cancel_help_info;
    : row {
     : text {
         key   = "AUT";
         label = "Written by: UD";
         alignment = left;
     }
     : button {
         label = "?";
         key = "Q";
         width  = 1;
         fixed_width  = true;
         alignment    = right;
     }
    }
}


<edit: code tags added>
  
« Last Edit: October 29, 2010, 07:44:03 PM by CAB »

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Need Help on Lisp & DCL
« Reply #1 on: October 29, 2010, 07:37:06 PM »
Firstly, read this  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need Help on Lisp & DCL
« Reply #2 on: October 29, 2010, 07:46:05 PM »
You can use them for other list as well to preserve the formatting.
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.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #3 on: October 30, 2010, 12:16:02 PM »
When I run it a will get an

“; error: bad argument type: stringp nil”

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need Help on Lisp & DCL
« Reply #4 on: October 30, 2010, 04:57:35 PM »
Here is a quick revision of your code. (NOT TESTED)
Without slides I can't test. Too much trouble to recreate them.

<edit: old code removed, see attachments in another post. CAB>
« Last Edit: October 31, 2010, 05:40:27 PM by CAB »
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.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #5 on: October 31, 2010, 12:53:18 AM »
I tried the revised code but I am still getting the same error message. I have added the slides, library, text file, lisp & dcl files.

Also I have included a snapshot on what I am trying to accomplish. I am curious on one thing. After seeing what I am trying to accomplish I am wondering if script files would be be needed to do this along with lisp and dcl.




roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Need Help on Lisp & DCL
« Reply #6 on: October 31, 2010, 08:00:04 AM »
@ laison :
If I test the original code there are 2 problems:
1.
#MENUDIR is not initialized. So using this code:
Code: [Select]
(strcat #MENUDIR ...)Causes an error.
2.
There is no function assembly
Code: [Select]
  (if (= OK 1)
    (assembly ASM)
  )

CAB's code for the dcl contains an error in line 3.
Old:
Code: [Select]
                action = "(setq ASM (strcat \"ASSEM\" (substr key$ 2)) (mode_tile \"accept\" 0) (set_tile \"AEC\" (lookup key$))";New:
Code: [Select]
                action = "(setq ASM (strcat \"ASSEM\" (substr $key 2))) (mode_tile \"accept\" 0) (set_tile \"AEC\" (cond ((lookup $key)) (\"\")))";
On a more principal level I would advise against the combination of tile actions programmed in lisp files, tile actions programmed in dcl files and script files.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need Help on Lisp & DCL
« Reply #7 on: October 31, 2010, 10:36:36 AM »
Thanks Roy but there were a few more errors.
Corrected routines attached.

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.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #8 on: October 31, 2010, 02:33:51 PM »
I just tried the routine. There is progress I think.

I got these error messages:

Error: in dialog file
"C:\Program Files\AutoCAD 2004\Support\Assemblies\ASSEM", line 15:

missing semicolon.

Error: in dialog file
"C:\Program Files\AutoCAD 2004\Support\Assemblies\ASSEM", line 15:

syntax error.

Symbol: "(setq ASM "ASSEM01")(mode_tile"accept"0)(set_tile "Assemblies"

"._Assembly01".

Error: in dialog file
"C:\Program Files\AutoCAD 2004\Support\Assemblies\ASSEM", line 15:

newline in string constant.



CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need Help on Lisp & DCL
« Reply #9 on: October 31, 2010, 02:47:17 PM »
Laison,
Did you try my DCL?

Those errors are not from my DCL. I eliminated this (mode_tile"accept"0)
among other changes.



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.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #10 on: October 31, 2010, 03:00:56 PM »
yes, I saved them and tried them and that is when I recieved the error messages.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #11 on: October 31, 2010, 03:04:05 PM »
I am not getting that far. The dcl will appear. I am getting these errors before the dcl is activated

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #12 on: October 31, 2010, 03:06:01 PM »
oops, I meant will not that the dcl will not appear.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Need Help on Lisp & DCL
« Reply #13 on: October 31, 2010, 05:21:18 PM »
You are not loading the correct DCL.

Let's try this another way. I attached a renamed version that will only load the renamed version.

Note that this line is hard coded in the lisp.
Code: [Select]
(setq #MENUDIR  "C:\Program Files\AutoCAD 2004\Support\Assemblies\ASSEM")  ; debug
PS  I added Help & Info functions which need to be edited by you.
« Last Edit: October 31, 2010, 05:39:18 PM by CAB »
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.

laison

  • Guest
Re: Need Help on Lisp & DCL
« Reply #14 on: October 31, 2010, 07:31:09 PM »
Cab

I just downloaded and tried the passem-cab & assembly-cab files.

I got this:

; error: quit / exit abort