See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: Lisp button to call a separate lisp routine in cad

  1. #1
    Member
    Join Date
    2005-10
    Posts
    4
    Login to Give a bone
    0

    Default Lisp button to call a separate lisp routine in cad

    I have a lisp routine that I want to call by using a dialog button from a separate autolisp DCL. I made the dialog box and the buttons but how can I call the separate lisp routine by pressing the button? I tried to put (command "name of lisp") for the button action, but it just keeps the dialog open and doesn't do anything. I am new to lisp, so if my question seems really stupid, I'm sorry, but if I can overcome this hurdle, I think I will be in good shape. All I need the button to do is write to the command line the lisp name and enter.

    Thanks
    Mike

  2. #2
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    Code:
    (action_tile "button-key" "(subfunction-name)")

  3. #3
    Member
    Join Date
    2005-10
    Posts
    4
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    I'm still confused why this isn't working. I have a lsp file I load into cad called hgr3.lsp The defun name in this lisp is defun c:hgr () I set the button to (action_tile "button-key" "(hgr)") but it just locks up the program. Sorry for my ignorance, probably something simple, but I can't figure it out.

    Thanks again

  4. #4
    Member
    Join Date
    2007-04
    Posts
    25
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    (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 an command_button
    (defun action_command (key)
    (cond
    ((= key 1)
    (alert "Please enter your command1:")
    ;;add your code in here
    )
    ((= 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
    )
    )
    )

  5. #5
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    Sachindkini, you forgot *.dcl :

    Code:
    //---------------------------------------------------------------------------------------------------------
    // Test
    //---------------------------------------------------------------------------------------------------------
    dcl_test : dialog {
      key = "Title";
      label = "Test commands dialog";
      spacer;
      : column {
        : button {
          key = "C1";
          label = "Command1"; 
          }
          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;
    }//Test

  6. #6
    Member
    Join Date
    2005-10
    Posts
    4
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    I am still unable to get the button to run the lisp by pushing it. If I put something like (command "circle") for the ;;add your code here area of the button action you provided below, it will invoke the circle command. But if I put (command "hgr") which would run the hgr lisp that is loaded in Cad to add hangers to the pipe runs it just returns "hgr Unknown command "HGR". Press F1 for help." If I just type hgr in the command line from within cad it does what it is supposed to do. I think I'm just to stupid to figure this out, I am greener than green with lisp. The reason I had hoped to accomplish this is that each button would be a particular hanger type with the appropriate spacing for a particular system. I was hoping to provide a dialog box with buttons to give a choice of system and hangers so whichever button was pushed it would invoke the assigned lisp routine. I appreciate all the help everyone provided and I apologize for my inabilities.

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,606
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    Quote Originally Posted by mlmoore View Post
    I am still unable to get the button to run the lisp by pushing it. If I put something like (command "circle") for the ;;add your code here area of the button action you provided below, it will invoke the circle command. But if I put (command "hgr") which would run the hgr lisp that is loaded in Cad to add hangers to the pipe runs it just returns "hgr Unknown command "HGR". Press F1 for help." If I just type hgr in the command line from within cad it does what it is supposed to do. I think I'm just to stupid to figure this out, I am greener than green with lisp. The reason I had hoped to accomplish this is that each button would be a particular hanger type with the appropriate spacing for a particular system. I was hoping to provide a dialog box with buttons to give a choice of system and hangers so whichever button was pushed it would invoke the assigned lisp routine. I appreciate all the help everyone provided and I apologize for my inabilities.
    Try (c:hgr) instead of (command "hgr"). If you post the code someone here will fix it for you.

  8. #8
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    1

    Default Re: Lisp button to call a separate lisp routine in cad

    Your defined function is command function and to call it from *.lsp, you have to name it as command function (c:hgr)... So try, instead of (hgr), (c:hgr)...

    M.R.
    I thought you're joking with us, so I waited to see if you'll find out... Well I guess nobody is perfect...

  9. #9
    Member
    Join Date
    2005-10
    Posts
    4
    Login to Give a bone
    0

    Default Re: Lisp button to call a separate lisp routine in cad

    Still no go, something so easy but I am unable to make it work. I have decided to forget about using a DCL and instead, I'll load the lisp files into my project and set up the commands using the CUI interface adding them as commands on a separate tool pallette just for hangers. I didn't even think of doing it this way until I discovered lisp was above my limited abilities. This will do the same thing as the dialog box was supposed to do and will finally put this nightmare to an end. I did learn a little about lisp and I really appreciate all the effort and time everyone gave to help me. It seems I'm just over my head trying to get a dialog button to invoke a lisp command. Something I thought would be easy was anything but. Thanks again for all your patience and help.

  10. #10
    Member
    Join Date
    2007-04
    Posts
    25
    Login to Give a bone
    0

    Thumbs up Re: Lisp button to call a separate lisp routine in cad

    Quote Originally Posted by marko_ribar View Post
    Sachindkini, you forgot *.dcl :

    Code:
    //---------------------------------------------------------------------------------------------------------
    // Test
    //---------------------------------------------------------------------------------------------------------
    dcl_test : dialog {
      key = "Title";
      label = "Test commands dialog";
      spacer;
      : column {
        : button {
          key = "C1";
          label = "Command1"; 
          }
          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;
    }//Test
    DEAR SIR
    THX

Similar Threads

  1. DCL LISP routine to call different functions
    By bhull1985403354 in forum AutoLISP
    Replies: 2
    Last Post: 2013-08-10, 04:28 PM
  2. Call MDDEDIT from a Lisp Routine
    By JeffClark in forum AutoCAD Customization
    Replies: 5
    Last Post: 2010-08-25, 08:47 PM
  3. Does this call for a lisp routine?
    By behrooz.mirfathali in forum AutoLISP
    Replies: 5
    Last Post: 2008-11-04, 03:10 PM
  4. Replies: 4
    Last Post: 2005-12-06, 04:17 PM
  5. How is your computer set up to call a LISP routine?
    By jack.frahm in forum AutoLISP
    Replies: 6
    Last Post: 2005-02-18, 01:52 PM

Posting Permissions

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