Jump to content

Recommended Posts

Posted

I try to write a code to get the arc length between any two points on it.

But my answer is wrong . why

( defun arclength()
 (setq ss (car (entsel "\nSelect arc:")))
 (setq x_object (vlax-Ename->Vla-Object ss))
 (setq r (vla-get-radius ename))
 (setq dist(getdist"/ pick on arc"))
 (setq dist2 (/ dist 2))
 (setq radian (atan  dist2 r))
 (setq distarc (* 2 r radian ))
 )

Posted

Try this:

(defun arclength ( / en di rd )
   (if
       (and
           (setq en (car (entsel "\nSelect Arc: ")))
           (= "ARC" (cdr (assoc 0 (entget en))))
           (setq di (getdist "\nPick Chord: "))
           (setq rd (cdr (assoc 40 (entget en))))
       )
       (* 2.0 rd (asin (/ di 2.0 rd)))
   )
)

;; ArcSine  -  Lee Mac
;; Args: -1 <= x <= 1

(defun asin ( x )
   (if (<= -1.0 x 1.0)
       (atan x (sqrt (- 1.0 (* x x))))
   )
)

ArcSine from here.

Posted (edited)

O.K Thanks it is working nicelly

Edited by wimal

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