Results 1 to 6 of 6

Thread: Repeat a command in lisp...

  1. #1
    Member
    Join Date
    2007-01
    Posts
    19
    Login to Give a bone
    0

    Default Repeat a command in lisp...

    I'm trying to get this sub-routine to ask a user to draw a line by picking two points. I don't want the user to have to do anything other than pick two points. They don't even have to hit enter. This works fine, the problem I'm having is repeating it an unlimited amount of times until the user hits ENTER.

    I know I can do this setting pt1 and pt2 variables and drawing a line between them, but I like the vanilla "line" command how it previews the line before you pick the 2nd point.

    The problem is at the 2nd "while".
    Here it is:

    Code:
    (defun polyop ()
    (command "-layer" "m" "Hal_Edge" "")
    (command "pline")
    (prompt "\nDraw slab edge at polygonal opening:")
    (while (= (getvar "cmdactive") 1) (command pause))
    (command "-layer" "m" "Hal_Cross" "")
    (while
    	(prompt "\nDraw crossing line:")
    	(command "line" pause pause "")
    )
    (princ)
    );defun
    (princ)

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Repeat a command in lisp...

    Quote Originally Posted by the_andyman17 View Post
    ....the problem I'm having is repeating it an unlimited amount of times until the user hits ENTER.
    Try this:

    Code:
    
    
    (command "._LINE")
    (while (eq 1 (logand (getvar"CMDACTIVE") 1))
      (command pause)
    )
    
    
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2007-01
    Posts
    19
    Login to Give a bone
    0

    Default Re: Repeat a command in lisp...

    Thanks, but that didn't work unfortunately.

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: Repeat a command in lisp...

    What doesn't work about it?
    R.K. McSwain | CAD Panacea |

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Repeat a command in lisp...

    Should work fine. One of the downfalls to using PAUSE is you lose any prompts. However, you can add your own...

    Code:
    (command "._LINE")
    (while (eq 1 (logand (getvar "CMDACTIVE") 1))
      (princ "\nSpecify point: ")
      (command pause)
    )

  6. #6
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: Repeat a command in lisp...

    Quote Originally Posted by alanjt View Post
    Should work fine. One of the downfalls to using PAUSE is you lose any prompts. However, you can add your own...
    I believe this is what the OP is looking for:
    Code:
    (defun polyop  (/ pt1 pt2)
     (command "._-layer" "_make" "Hal_Edge" "")
     (command "._pline")
     (prompt "\nDraw slab edge at polygonal opening: ")
     (while (= (getvar "cmdactive") 1) (command pause))
     (command "._-layer" "_make" "Hal_Cross" "")
     (while (and (setq pt1 (getpoint "\nSpecify first point: "))
                 (setq pt2 (getpoint pt1 "\nSpecify second point: ")))
      (command "._line" pt1 pt2 ""))
     (princ))
    (princ)
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

Similar Threads

  1. Repeat Last Command
    By gmg in forum Revit - Platform
    Replies: 4
    Last Post: 2013-04-20, 10:29 PM
  2. Repeat last command
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 1
    Last Post: 2013-01-04, 05:39 PM
  3. Command alias repeat on the command line
    By rbilger in forum AutoCAD General
    Replies: 8
    Last Post: 2011-08-18, 09:47 PM
  4. repeat command
    By Ning Zhou in forum Revit Architecture - General
    Replies: 2
    Last Post: 2009-12-14, 07:59 PM
  5. Right Click to repeat Command
    By margaretl in forum AutoLISP
    Replies: 3
    Last Post: 2007-07-27, 08:37 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
  •