Jump to content

Help tracking from a point in a loop (while)


Recommended Posts

Posted

Long time lurker, first time poster.

 

I'm having trouble with a lisp. Below is an oversimplification of what I'm trying to do but the hangup is here.

 

I'm trying to create a series of points while tracking from "pt1". It will work the first time but then ends the command.

 

(DEFUN C:test ()

(while

(setq pt1 (LIST 0 0))

(command "POINT" "_tt" pt1 pause)

)

(princ)

)

 

If I remove the { "_tt" pt1 }, which is what tells it to track, the command will run continuously, as wanted, but if I tell it to track it works once then stops.

 

Help please?

Posted

If I understand correctly, maybe :

 

(defun c:foo (/ bp pt1)
  (setq bp (list 0 0 0)
  (while (setq pt1 (getpoint bp "\nNext Point:   "))
         (command "_.POINT" "_non" pt1))
(prin1))

 

 

Not tested

 

-David

Posted

Thanks David but I need it to track from within the "point" command not before the point is created as you have it.

Posted

David's code tracks from one point ( which you asked for ) .. perhaps you're looking to change p1 to the last point picked in a loop? Here's some old code from my library:

(defun c:mdist (/ d p1 p2 v)
 (setq d 0)
 (while (and (or p1 (setq p1 (getpoint "\nSpecify start point: ")))
      (setq p2 (getpoint p1 "\nSpecify next point: "))
      (setq d (+ d (distance p1 p2)))
      (setq v (append v (list p1 p2)))
      (setq p1 p2)
 )
   (grvecs (append v '(1)))
   (princ (strcat "\nRunning total: " (rtos d)))
 )
 (princ)
)

 

Or this?

(defun c:test (/ p1 p2)
 (while (and (or p1 (setq p1 (getpoint "\nSpecify start point: ")))
      (setq p2 (getpoint p1 "\nSpecify next point: "))
 )
   (entmakex (list '(0 . "point") (cons 10 p1) '(8 . "point")))
   (setq p1 p2)
 )
 (princ)
)

Posted

Do you understand that (command) always returns nil. (AFAIK) ?

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