Jump to content

Recommended Posts

Posted

can anyone help i am trying to find the command to cancel. I have a lisp that just keeps running over and over until i press esc.

Posted

Is the program stuck in a loop or does it continuously prompt for user input?

Posted

This is the code i have.

 

(defun c:wa () 
(command "area" "o" pause) then
 (setq    STRTAB (getpoint "\nLocate a Start Point For Text  ")
   z      27
   SCF    (getvar "USERR4")
 )
 (command "osnap" "NONE")
 (setq    es (car strtab)
   ns (cdr strtab)
   ns (- (car ns) (* SCF 3.5))
 )
 (while z
   (setq S1 (list es ns)
     S2 (list (+ (* SCF 0. es) ns)
   )
   (command "LAYER" "m" "AREA" "c" "yellow" "" "")
   (setq ONE (command "text" "s" "TTS" "j" "r" S1 90.0 (strcat (rtos (getvar "area") '2 '0))))
   (command "layer" "m" "AREA" "c" "yellow" "" "")
   (setq TWO (command "text" "s" "AREA" "j" "l" S2 90.0 "m%%2012"))
 )
)

Posted
This is the code i have.

 

(defun c:wa () 
(command "area" "o" pause) then
 (setq    STRTAB (getpoint "\nLocate a Start Point For Text  ")
   z      27
   SCF    (getvar "USERR4")
 )
 (command "osnap" "NONE")
 (setq    es (car strtab)
   ns (cdr strtab)
   ns (- (car ns) (* SCF 3.5))
 )
 (while z
   (setq S1 (list es ns)
     S2 (list (+ (* SCF 0. es) ns)
   )
   (command "LAYER" "m" "AREA" "c" "yellow" "" "")
   (setq ONE (command "text" "s" "TTS" "j" "r" S1 90.0 (strcat (rtos (getvar "area") '2 '0))))
   (command "layer" "m" "AREA" "c" "yellow" "" "")
   (setq TWO (command "text" "s" "AREA" "j" "l" S2 90.0 "m%%2012"))
 )
)

 

 

Perhaps because '(while z' will always be true? You no nowhere make it nil

 

 

gr. Rlx

Posted

i took while z out and it works thanks

 

(defun c:wa ()
(command "area" "o" pause) then
 (setq    STRTAB (getpoint "\nLocate a Start Point For Text  ")
   z      27
   SCF    (getvar "USERR4")
 )
 (command "osnap" "NONE")
 (setq    es (car strtab)
   ns (cdr strtab)
   ns (- (car ns) (* SCF 3.5))
 )
   (setq S1 (list es ns)
     S2 (list (+ (* SCF 0. es) ns)
   )
   (command "LAYER" "m" "AREA" "c" "yellow" "" "")
   (setq ONE (command "text" "s" "TTS" "j" "r" S1 90.0 (strcat (rtos (getvar "area") '2 '0))))
   (command "layer" "m" "AREA" "c" "yellow" "" "")
   (setq TWO (command "text" "s" "AREA" "j" "l" S2 90.0 "m%%2012"))
)

Posted (edited)

This is incomplete but, it should help you move away from the command function

 

(defun RB:HowItsMade ( obj / RB:pad )
 (defun RB:pad ( int )
 (
   (lambda ( str )
     (repeat int
       (setq str (strcat " " str))
     ) str
   ) ""
 )
)
 (and (eq 'VLA-OBJECT (type obj))
   (setq obj (handent (vla-get-handle obj)))
 )
 (
   (lambda ( n / flag )
     (foreach x 
       (append (list "(entmakex" "(list")
         (entget obj '("Acad"))
       )
       (if
         (or (eq 'STR (type x))
           (not
             (or (eq 5 (car x))
               (eq 'ENAME (type (cdr x)))
             )
           )
         )
         (princ 
           (strcat "\n" (rb:pad n) 
             (if (listp x) 
               (strcat "(cons " (vl-princ-to-string (car x)) " "
                 (cond
                   ( (listp (cdr x)) (strcat "'" (vl-princ-to-string (cdr x))) )
                   ( (eq 'STR (type (cdr x)))
                     (strcat "\"" (vl-princ-to-string (cdr x)) "\"")
                   ) ( (vl-princ-to-string (cdr x)) )  
                 ) ")"
               ) x
             )
           )
         )
       )
       (if (not (vl-string-search ")" (vl-princ-to-string x)))
         (setq n (+ 2 n))
       )
     )
     (repeat (/ n 2)
       (princ (strcat "\n" (rb:pad (setq n (- n 2))) ")"))
     )(princ)
   ) 0 
 )
)

example:

(rb:howitsmade (car (entsel "\nSelect object to see how it's made: ")))

Edited by Lt Dan's legs

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...