Jump to content

Execute ENTMAKE within a loop REPEAT only ONCE


ojacomarket

Recommended Posts

Dear friends,

 

I have an issue.

Is it possible somehow to ESTABLISH some kind of condition to EXECUTE some routine only ONCE inside the loop.

For example,

 

I have a loop that draws circles, then I want to stop looping and draw one more circle in specific place and then end the loop.

Link to comment
Share on other sites

(defun c:example ( / pt rad)
  (setq rad 1)	; <--- Circle radius
  (while (setq pt (getpoint "\nSpecify center: "))
    (entmake (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 rad)))
    )
  (entmake
    (list
      '(0 . "CIRCLE")
      (cons 10 (progn (initget 1) (getpoint "\nSpecify center for last circle: ")))
      (cons 40 rad)
      )
    )
  (princ)
  )

 

  • Thanks 1
Link to comment
Share on other sites

Johnathon ahs provided an answer but why not just draw the last circle or is there something your not telling us ?

 

(while (setq pt (getpoint "\nSpecify center Enter to exit: "))

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
On 4/13/2020 at 11:16 AM, ojacomarket said:

Dear friends,

 

I have an issue.

Is it possible somehow to ESTABLISH some kind of condition to EXECUTE some routine only ONCE inside the loop.

For example,

 

I have a loop that draws circles, then I want to stop looping and draw one more circle in specific place and then end the loop.

 

@ojacomarket to just answer your question, add a conditional flag within your loop that is set to T after the single execution:

(While (/= (getkword "\nEnter 'E' to exit or <ENTER> to continue: ") "E")
   (if (= flag nil)
      (progn
         (alert "Setting Flag!")
         (setq Flag T)
      )
      (princ "\nFlag Set! ")
   )
)

 

Link to comment
Share on other sites

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...