Jump to content

mid line from center arc to center chord


land

Recommended Posts

Welcome to Cadtutor

Maybe this will help you, but if it's a polyline with more elements or it's a line this just won't work

;;; c2mpt Line from Midpoint of chord to Midpoint of an arc
;;; 20221225 Isaac A.
;;; https://www.cadtutor.net/forum/topic/76534-mid-line-from-center-arc-to-center-chord/
(vl-load-com)
(defun c:c2mpt (/ a b c d e oe oo ve)
   (setq oe (getvar 'cmdecho)
         oo (getvar 'osmode)
   )
   (setvar 'cmdecho 0)
   (vl-cmdf "_.undo" "_begin")
   (setvar 'osmode 37)
   (princ "\nProgram to create a line from midpoint of chord to midpoint of an arc ")
   (setq e  (car (entsel "\nSelect the element: "))
         ve (vlax-ename->vla-object   e)
         a  (vlax-curve-getStartPoint ve)
         b  (vlax-curve-getEndPoint   ve)
         c  (ia:midp a b)
	 d  (if (= (cdr (assoc 0 (entget e))) "ARC")
               (vlax-curve-getPointAtDist ve (* 0.5 (vla-get-ArcLength ve)))
               (vlax-curve-getPointAtDist ve (* 0.5 (vla-get-length ve)))
	    )
   )
   (vl-cmdf "line" "_non" c "_non" d "")
   (setvar 'osmode oo)
   (setvar 'cmdecho oe)
   (vl-cmdf "_.undo" "_end")
   (princ "\n")
   (princ)
)

;;; ia:midp
;;; Returns the midpoint of 2 given points
(defun ia:midp (a b)
  (mapcar '* (mapcar '+ a b) '(0.5 0.5 0.5))
)

 

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

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