Results 1 to 5 of 5

Thread: Calling a script from with in a lisp

  1. #1

    Default Calling a script from with in a lisp

    I am trying to call a script file from a button in a dialog box. If I write a simple lisp that calls the script only, it works fine. However, when I add the dcl programming, the lisp just hangs AutoCad. Any ideas? Thank you in advance. Can't seem to attach a file so the lsp, dcl, and scr code is below:

    Lisp FIle:

    Code:
    (defun C:test( / id i ok)
     (setq id (load_dialog "test.DCL")) ;load DCL
     (if (new_dialog "dcl_test" id)
     (progn
     (setq i 1)
     (repeat 6
     (init_image i) ;assign an action to the image_button
     ;(action_image i) 
    (setq i (1+ I)) 
    )
     (action_tile "C1" "(action_command 1)") ;assign an action to the button 1
     (action_tile "C2" "(action_command 2)") ;assign an action to the button 2
     (action_tile "C3" "(action_command 3)") ;assign an action to the button 3
     (action_tile "C4" "(action_command 4)") ;assign an action to the button 4
     (action_tile "C5" "(action_command 5)") ;assign an action to the button 5
     (action_tile "C6" "(action_command 6)") ;assign an action to the button 6
     
    ;;of course ,you can do it by (repeat)
     (setq ok (start_dialog))
     )
     (alert "Can't load the dialoag!")
     )
     (unload_dialog ID)
     (princ)
     )
     
    ;;; initializate the image_button.
     ;;; and assign an action to an image_button
     (defun init_image (key / k tile)
     (setq k (itoa key))
     (setq tile (strcat "I" k)) ;tile
     (start_image tile)
     (fill_image
     0
     0
     (dimx_tile tile)
     (dimy_tile tile)
     key
     )
     (end_image) ;fill tile with different color
     (set_tile tile (strcat "Fun" k)) ;set the text of tile
     (action_tile tile (strcat "(action_command " k ")")) ;action
     )
     
    ;;; assign an action to a command_button
     (defun action_command (key)
     (cond
     ((= key 1)
     ;;(alert "Please enter your command1:")
     ;;add your code in here
     (command "script" "sl1.scr")
     
      )
     ((= key 2)
     (alert "Please enter your command2:")
     ;;add your code in here
     )
     ((= key 3)
     (alert "Please enter your command3:")
     ;;add your code in here
     )
     ((= key 4)
     (alert "Please enter your command4:")
     ;;add your code in here
     )
     ((= key 5)
     (alert "Please enter your command5:")
     ;;add your code in here
     )
    ((= key 6)
     (alert "Please enter your command6:")
     ;;add your code in here
     )
     )
     )
    DCL File:


    Code:
    dcl_test : dialog {
      key = "Title";
      label = "Test commands dialog";
      spacer;
      : column {
        : button {
          key = "C1";
          label = "SL1"; 
          }
          spacer;
        : button {
          key = "C2";
          label = "Command2"; 
          }
          spacer;
        : button {
          key = "C3";
          label = "Command3"; 
          }
          spacer;
        : button {
          key = "C4";
          label = "Command4"; 
          }
          spacer;
        : button {
          key = "C5";
          label = "Command5"; 
          }
      }
    spacer;
      ok_only;
    }//Testap
    Script File:

    Code:
    -LAYER
    ON
    AV-SHBD-VIEW
    mview
    lock
    off
    .291,.297
    mspace
    zoom
    W
    0,77.6
    27.8,56
    pspace
    mview
    lock
    on
    .291,.297
    -layer
    off
    AV-SHBD-VIEW
    Last edited by Ed Jobe; 2012-06-05 at 03:17 PM. Reason: Added code tags

  2. #2
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    4,776

    Default Re: Calling a script from with in a lisp

    Welcome to augi.

    To attach files, click on the 'Go Advanced' button when in edit mode. There are also buttons for enclosing your code as I've done for you.
    C:> ED WORKING....

  3. #3
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,383

    Default Re: Calling a script from with in a lisp

    Quote Originally Posted by randy.sherwood597724 View Post
    I am trying to call a script file from a button in a dialog box.
    There's no need to use the Script at all, other than that you want to. All tasks performed in your Script can be done in LISP AFAIK, and would also simplify matters IMO.

    HTH
    "Potential has a shelf life." - Margaret Atwood

  4. #4

    Default Re: Calling a script from with in a lisp

    I tried that first, and it does not work either. You can call a simple command, such as "circle" but you cannot call the layer command and include the responses as in my script file. At least I was not able to. I am trying to do this from a dialog box.

  5. #5
    Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    2,383

    Default Re: Calling a script from with in a lisp

    Give this a try:

    Code:
    (defun _DoIt ()
      (command "._-layer" "on" "AV-SHBD-VIEW" "")
      (command "._mview" "lock" "off" "_non" '(0.291 0.297))
      (command "._mspace")
      (command "._zoom" "window" "_non" '(0.0 77.6) "_non" '(27.8 56.0))
      (command "._pspace")
      (command "._mview" "lock" "on" "_non" '(0.291 0.297))
      (command "._-layer" "off" "AV-SHBD-VIEW" "")
      (princ))
    ** Note - Code assumes that the "AV-SHBD-VIEW" layer, and that a PViewport already exists within the drawing this code is called from at the designated location(s). Error checking not included.
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. php script in Lisp
    By dryman537226 in forum AutoLISP
    Replies: 0
    Last Post: 2011-03-08, 07:54 AM
  2. Calling up LISP routine from within another LISP
    By jimmy_goodall in forum AutoLISP
    Replies: 2
    Last Post: 2010-02-01, 05:41 AM
  3. Multiple Menu items calling the same lisp?
    By stevenw00 in forum AutoLISP
    Replies: 8
    Last Post: 2009-08-13, 11:26 AM
  4. PDF plot w/lisp and script
    By jeff.smith in forum AutoCAD Plotting
    Replies: 2
    Last Post: 2008-12-18, 06:34 AM
  5. Calling a lisp from within a lisp
    By LanceMcHatton in forum AutoLISP
    Replies: 10
    Last Post: 2005-10-16, 02:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •