Jump to content

Help please: Create point between 2 points in 3d


Recommended Posts

Posted

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/

 

Posted (edited)
(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
Posted
18 minutes ago, mhupp said:
(prompt (strcat "\nThe midpoint is: " mid))

(prompt (strcat "\nThe midpoint is: " (vl-prin1-to-string mid)))

  • Like 1
Posted

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.

Posted

Thank you 1958, I'll try your suggestion.

Posted

Sorry guys, it still isn't creating a Point in between. I'll keep on trying to see what's wrong

Posted (edited)

See updated code

 

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

Edited by mhupp
Posted

Hi mhupp, is it possible to create a Point @ that coordinate as well ?

Posted (edited)

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
Posted

Yeah, I've tried making PTYPE larger, but I'm still not seeing a Point like below @ that coordinate

image.png.a423b7fe9f0e82815835ec5fedbfe513.png

Posted

Amazing! It works! Thank you so much for your help mhupp!

  • Like 1

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