Author Topic: help locating a code to draw arc length  (Read 470 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: 2308
• 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]
1. (defun c:arcstptenptlength ( / ArcStartEndLength p1 p2 len )
2.
3.   (defun ArcStartEndLength ( startPoint endPoint arcLength
4.                             / newton chord ang rad mid cen )
5.
6.     ;; use the Newton method to compute the arc half angle according to its length and chord
7.     (defun newton ( arc chord / k x )
8.       (setq k (/ chord arc)
9.             x (sqrt (- 6 (* 6 k)))
10.       )
11.       (repeat 6
12.         (setq x (- x (/ (- (sin x) (* k x)) (- (cos x) k))))
13.       )
14.     )
15.
16.     (setq chord (distance startPoint endPoint))
17.     (if (< chord arcLength)
18.         (setq ang (newton arcLength chord)
19.               rad (abs (/ chord 2. (sin ang)))
20.               mid (mapcar '(lambda ( p1 p2 ) (/ (+ p1 p2) 2.0))
21.                           startPoint
22.                           endPoint
23.                   )
24.         )
25.         (if (equal (/ pi 2) ang 1e-009)
26.           (setq cen mid
27.                rad (/ chord 2.)
28.           )
29.           (setq
30.             cen (polar mid
31.                      (+ (angle startPoint endPoint) (/ pi 2))
32.                      (* rad (cos ang))
33.                 )
34.           )
35.         )
36.           (list
37.             (cons 0 "ARC")
38.             (cons 10 cen)
39.             (cons 40 rad)
40.             (cons 50 (angle cen startPoint))
41.             (cons 51 (angle cen endPoint))
42.           )
43.         )
44.       )
45.     )
46.   )
47.
48.   (setq p1 (getpoint "\nPick or specify start point of arc : "))
49.   (setq p2 (getpoint "\nPick or specify end point of arc : "))
50.   (initget 7)
51.   (setq len (getdist (strcat "\nPick or specify arc length (must be larger than : " (rtos (distance p1 p2) 2 20) ") : ")))
52.   (while (<= len (distance p1 p2))
53.     (prompt "\nArc length must be larger than : ") (princ (rtos (distance p1 p2) 2 20)) (prompt "... Pick or specify length again : ")
54.     (setq len (getdist))
55.   )
56.   (ArcStartEndLength p1 p2 len)
57.   (princ)
58. )
59.

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

gile

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

There was also this reply.
Speaking English as a French Frog

Lee Mac

• Seagull
• Posts: 12368
• London, England
Re: help locating a code to draw arc length
« Reply #3 on: March 20, 2019, 05:48:51 PM »