Results 1 to 3 of 3

Thread: how do i loop this?

  1. #1
    100 Club
    Join Date
    2009-07
    Posts
    103
    Login to Give a bone
    0

    Default how do i loop this?

    i have this lisp and i want to be able to make it loop, how do i fix it so it will loop?

    Code:
    ;  COORD.LSP-Place a north/east/elevation coordinate label at given location
    ;  USAGE:
    ;
    ;  Command: (load "COORD") [ENTER]
    ;  C:COORD
    ;
    ;  Command: COORD [ENTER]
    ;  COORD
    ;  Indicate point to define: <select point>
    ;  Starting point for label: <select point>
    ;  Indicate point to define:  [ENTER]     <=- [ENTER] at this prompt ends COORD
    
    (defun c:crd ( / dimsc N E Z p1 p2 p3 p4 p5 p6)
       (setvar "cmdecho" 0)
       (setq dimsc (getvar "dimscale"))
       (setq p1 (getpoint "\nIndicate point to define: "))
       (setq p2 (getpoint "\nStarting point for label: "))
       (setq p3 (polar p2 0.785390 (* 0.05 dimsc)))
       (setq p4 (polar p2 5.03414 (* 0.15811 dimsc)))
       (setq p6 (polar p2 11.1630 (* 0.30000 dimsc)))
       (setq e (rtos (car p1)))
       (setq n (rtos (cadr p1)))
       (setq p5 (polar p2 0 (* (+ 1.5 (max (strlen e)(strlen n)))(* 0.12 dimsc))))
       (command "text" p3 (* dimsc 0.12) "0" (strcat "N " n)) 
       (command "text" p4 (* dimsc 0.12) "0" (strcat "E " e))
       (command "line" p1 p2 p5 "")
       
       (if (and (> (angle p1 p2) 1.5708)
                (< (angle p1 p2) 4.71239)
           )     
                (command "move" "c" p3 p4 "r" p1 "" p5 p2)
       )
       (setvar "cmdecho" 1) 
       (princ)
    Last edited by Opie; 2009-07-31 at 04:37 PM. Reason: [code] tags added

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

    Default Re: how do i loop this?

    Here is one way.

    Code:
    
    (defun c:crd (/ dimsc N E Z p1 p2 p3 p4 p5 p6)
      (setvar "cmdecho" 0)
      (setq dimsc (getvar "dimscale"))
      (while
        (setq p1 (getpoint "\nIndicate point to define: "))
         (setq p2 (getpoint "\nStarting point for label: "))
         (setq p3 (polar p2 0.785390 (* 0.05 dimsc)))
         (setq p4 (polar p2 5.03414 (* 0.15811 dimsc)))
         (setq p6 (polar p2 11.1630 (* 0.30000 dimsc)))
         (setq e (rtos (car p1)))
         (setq n (rtos (cadr p1)))
         (setq
           p5 (polar p2
    		 0
    		 (* (+ 1.5 (max (strlen e) (strlen n))) (* 0.12 dimsc))
    	  )
         )
         (command "text" p3 (* dimsc 0.12) "0" (strcat "N " n))
         (command "text" p4 (* dimsc 0.12) "0" (strcat "E " e))
         (command "line" p1 p2 p5 "")
    
         (if (and (> (angle p1 p2) 1.5708)
    	      (< (angle p1 p2) 4.71239)
    	 )
           (command "move" "c" p3 p4 "r" p1 "" p5 p2)
         )
      )
      (setvar "cmdecho" 1)
      (princ)
    )
    
    R.K. McSwain | CAD Panacea |

  3. #3
    100 Club
    Join Date
    2009-07
    Posts
    103
    Login to Give a bone
    0

    Talking Re: how do i loop this?

    thanks for the help, I really appreciate it

Similar Threads

  1. End of while loop...
    By marko_ribar in forum AutoLISP
    Replies: 11
    Last Post: 2010-10-20, 07:55 PM
  2. create a loop
    By buckingmule in forum AutoLISP
    Replies: 4
    Last Post: 2009-06-03, 03:21 PM
  3. loop leader
    By FOUTJM in forum Revit Structure - Families
    Replies: 0
    Last Post: 2007-01-30, 05:56 PM
  4. Block Insert Array (Loop within a Loop)
    By wpeacock in forum VBA/COM Interop
    Replies: 2
    Last Post: 2005-06-14, 04:24 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
  •