Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: End of while loop...

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

    Question End of while loop...

    Whats wrong in these lines... I want to end while loop by setting its condition to nil (setq q 1)... This should imitate command PLINE - closed, and when start point eqauls end point it should end loop, and make polyline from sequence of lines...

    Code:
    (setq sslin (ssadd))
    (setq q -1)
    (setq pt (getpoint))
    (setq ptt pt)
    (while (< q 0)
    (progn
    (command "line" pt (setq pt (getpoint pt)) "")
    (ssadd (entlast) sslin)
    (if (eq pt ptt) (setq q 1))
    ))
    (command "pedit" (entlast) "" "j" sslin "" "")
    Thanks...
    M.R.

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

    Smile Re: End of while loop...

    I have found solution. It was (equal pt ptt) insted of (eq pt ptt)...

    Code:
    (setq sslin (ssadd))
    (setq q -1)
    (setq pt (getpoint))
    (setq ptt pt)
    (while (< q 0)
    (progn
    (command "line" pt (setq pt (getpoint pt)) "")
    (ssadd (entlast) sslin)
    (if (equal pt ptt) (setq q 1))
    ))
    (command "pedit" (entlast) "" "j" sslin "" "")

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

    Default Re: End of while loop...

    Just use the PLine command.

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

    Default Re: End of while loop...

    I can't use pline command, for it doesn't end quietly... Try to continue routine after pline command like (setq e (entlast)) where (entlast) would be that pline... Instead this functions, but only thing is that it would be prettier if it would have option "C" - close, like pline has... Any idea how to add that "C" option to (getpoint) function where it would pass that "c" to my ptt point - start=end point...

    or return nil after (getpoint), like I explained in next post
    M.R.
    Last edited by marko_ribar; 2010-10-19 at 07:50 AM.

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

    Red face Re: End of while loop...

    In another word, I want to manipulate with that polyline after its created, like I selected it here :

    Code:
    (defun c:plsel ()
    (setq sslin (ssadd))
    (setq q -1)
    (setq pt (getpoint "\nPick first point of polyline"))
    (setq ptt pt)
    (while (< q 0)
    (progn
    (command "line" pt (setq pt (getpoint pt)) "")
    (ssadd (entlast) sslin)
    (if (or (equal pt ptt) (eq pt nil)) (setq q 1))
    ))
    (command "pedit" (entlast) "" "j" sslin "" "")
    (setq s (ssadd))
    (ssadd (entlast) s)
    (sssetfirst s s)
    (princ)
    )
    but, unfortunately when I enter "c" close option (getpoint) returns invalid point, and when I type ENTER to exit (getpoint) it returns nil witch I used to also terminate while loop...

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

    Cool Re: End of while loop...

    I have solved the problem :

    Code:
    (defun c:plsel ()
    (setq sslin (ssadd))
    (setq q -1)
    (setq pt (getpoint "\nPick first point of polyline"))
    (setq ptt pt)
    (while (< q 0)
    (progn
    (initget 8 "c C Close")
    (command "line" pt (if (equal (setq pt (getpoint pt "\nor type <c/C/Close> to close pline : ")) "C")(setq pt ptt)(setq pt pt)) "")
    (ssadd (entlast) sslin)
    (if (or (equal pt ptt) (eq pt nil)) (setq q 1))
    ))
    (command "pedit" (entlast) "" "j" sslin "" "")
    (setq s (ssadd))
    (ssadd (entlast) s)
    (sssetfirst s s)
    (princ)
    )
    It now has "Close" option...

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

    Default Re: End of while loop...

    Quote Originally Posted by marko_ribar View Post
    I can't use pline command, for it doesn't end quietly... Try to continue routine after pline command like (setq e (entlast)) where (entlast) would be that pline...
    Look at the code and you'll see that with (command "pline" pt (while...(command pt)) ""), command terminates with :; error: Function cancelled, and then it continues to execute pline command like there aren't "") sign for quiet exit, and after this it doesn't continue to execute next lines in routine...

    Code:
    (defun c:plsel ()
    (setq pt (getpoint "\nPick first point of polyline"))
    (setq ptt pt)
    (setq q -1)
    (command "pline" pt 
    (while (< q 0)
    (progn
    (initget 8 "c C Close")
    (command (if (equal (setq pt (getpoint pt "\nor type <c,C,Close> to close polyline : ")) "C")(setq pt ptt)(setq pt pt)) )
    (if (or (equal pt ptt)(eq pt nil))(setq q 1))
    ))
    "")
    (setq el (entlast))
    (setq s (ssadd))
    (ssadd el s)
    (sssetfirst s s)
    (princ)
    )
    Any corrections to given code will be appreciated...

    M.R.

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

    Default Re: End of while loop...

    Code:
    (Command "_.pline")
    (While (eq 1 (logand 1 (getvar 'cmdactive))) (command pause))
    Stupid titlecase on my phone
    Last edited by alanjt; 2010-10-19 at 01:40 PM.

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

    Thumbs up Re: End of while loop...

    Thanks, Alanjt...

    this works, although I don't know how...
    and it looks simple - in 3 lines...

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

    Default Re: End of while loop...

    Actually, you don't need the last line (shows what happens when you type code from a phone).

    It uses while and as long as the command is running active commands (cmdactive), it will supply it with (command PAUSE).

Page 1 of 2 12 LastLast

Similar Threads

  1. how do i loop this?
    By mgonzales.224492 in forum AutoLISP
    Replies: 2
    Last Post: 2009-07-31, 06:41 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
  •