### Author Topic: help locating a code to draw arc length  (Read 121 times)

0 Members and 1 Guest are viewing this topic.

#### andrew..

• Mosquito
• Posts: 20
##### help locating a code to draw arc length
« on: March 20, 2019, 03:05:26 PM »
a few years ago there was code shared that draws arc length based on numeric input.
I can not seem to located it here.
Would anyone happen to have a copy of it they can share?

thanks

#### ribarm

• Water Moccasin
• Posts: 2052
• Marko Ribar, architect
##### Re: help locating a code to draw arc length
« Reply #1 on: March 20, 2019, 03:37:51 PM »
I've found something posted by I think @gile at autodesk forums... It's based on Newton's formula :

Code - Auto/Visual Lisp: [Select]
`(defun c:arcstptenptlength ( / ArcStartEndLength p1 p2 len )   (defun ArcStartEndLength ( startPoint endPoint arcLength                            / newton chord ang rad mid cen )     ;; use the Newton method to compute the arc half angle according to its length and chord    (defun newton ( arc chord / k x )      (setq k (/ chord arc)            x (sqrt (- 6 (* 6 k)))      )      (repeat 6        (setq x (- x (/ (- (sin x) (* k x)) (- (cos x) k))))      )    )     (setq chord (distance startPoint endPoint))    (if (< chord arcLength)      (progn        (setq ang (newton arcLength chord)              rad (abs (/ chord 2. (sin ang)))              mid (mapcar '(lambda ( p1 p2 ) (/ (+ p1 p2) 2.0))                          startPoint                          endPoint                  )        )        (if (equal (/ pi 2) ang 1e-009)          (setq cen mid               rad (/ chord 2.)          )          (setq            cen (polar mid                     (+ (angle startPoint endPoint) (/ pi 2))                     (* rad (cos ang))                )          )        )        (entmakex          (list            (cons 0 "ARC")            (cons 10 cen)            (cons 40 rad)            (cons 50 (angle cen startPoint))            (cons 51 (angle cen endPoint))          )        )      )    )  )   (setq p1 (getpoint "\nPick or specify start point of arc : "))  (setq p2 (getpoint "\nPick or specify end point of arc : "))  (initget 7)  (setq len (getdist (strcat "\nPick or specify arc length (must be larger than : " (rtos (distance p1 p2) 2 20) ") : ")))  (while (<= len (distance p1 p2))    (prompt "\nArc length must be larger than : ") (princ (rtos (distance p1 p2) 2 20)) (prompt "... Pick or specify length again : ")    (setq len (getdist))  )  (ArcStartEndLength p1 p2 len)  (princ)) `

HTH., M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### gile

• Water Moccasin
• Posts: 2195
• Marseille, France
##### Re: help locating a code to draw arc length
« Reply #2 on: March 20, 2019, 03:42:31 PM »
Hi,