Jump to content

Help please: Create point between 2 points in 3d


barristann

Recommended Posts

Hi all,

Anyone knows how to modify this code to place a point in between 2 other points in 3D? The below codes belong to PBe and Lee Mac: 

 

(defun c:FOO (/ pt1 pt2 mid)
 (if (and (setq pt1 (getpoint "\n  >>  Specify first point: "))
   (setq pt2 (getpoint "\n  >>  Specify second point: "))
     )
   (progn
     (prompt "\n<<  The midpoint is: ")

      (reverse (cons (/ (+ (last pt1) (last pt2)) 2) (cdr (reverse (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0))
        )
    )
 )
      )
     )
   )
 )

 

 

https://www.cadtutor.net/forum/topic/27359-mid-of-2-points/

 

Link to comment
Share on other sites

(defun c:FOO (/ pt1 pt2 mid)
  (if (and (setq pt1 (getpoint "\nSpecify first point: ")) (setq pt2 (getpoint "\nSpecify second point: ")))
    (progn
      (setq mid (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2)))
      (prompt "\nThe midpoint is: ")
      (princ mid)
    )
  )
  (princ)
)

 

-Edit

their is also a snap m2p

Edited by mhupp
Link to comment
Share on other sites

Thank you for your help mhupp. It says:

 

Cannot invoke (command) from *error* without prior call to (*push-error-using-command*).
Converting (command) calls to (command-s) is recommended.

Link to comment
Share on other sites

See updated code

 

Specify first point:
Specify second point:
The midpoint is: (5.84985571613485 4.02541296060991 5.0)

Edited by mhupp
Link to comment
Share on other sites

mid is the point

 

(defun c:FOO (/ pt1 pt2 mid)
  (if (and (setq pt1 (getpoint "\nSpecify first point: ")) (setq pt2 (getpoint "\nSpecify second point: ")))
    (progn
      (setq mid (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2)))
      (prompt "\nThe midpoint is: ")
      (princ mid)
      (entmake (list (cons 0 "POINT") (cons 10 mid)))
    )
  )
  (princ)
)
Edited by mhupp
  • Like 2
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...