AutoCAD/Arc-length from known radius & chord
Expert: Bill DeShawn - 7/31/2006
QuestionHi,
I have a radius of 1326.0
And a chord of 72.0
How can I find the arch length using autolisp?
AnswerDan: Check this out:
(defun c:aleng (/ os snp ortho xcmdecho arcsel arcpick arcpick2 arclst etype arcstart aracend arcrad arcang)
(command "undo" "_g")
(setvar "textsize" (* 0.0666667 (getvar "dimscale")))
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq snp (getvar "snapmode"))
(setvar "snapmode" 0)
(setq ortho (getvar "orthomode"))
(setvar "orthomode" 0)
(setq xcmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq arcsel (entsel))
(setq arcpick (car (cdr arcsel)))
(setq arcpick2 (osnap arcpick "nea"))
(setq arclst (entget (car arcsel)))
(setq etype (cdr (assoc 0 arclst)))
(cond
((= etype "ARC")
(setq arcstart (cdr (assoc 50 arclst)))
(setq arcend (cdr (assoc 51 arclst)))
(setq arcrad (cdr (assoc 40 arclst)))
(setq arcang (- arcend arcstart))
(if (< arcang 0)
(setq arcang (+ arcang 6.283185))
)
(setq arclen (rtos (/ (* arcrad arcang) 12) 2 2))
; (command "dim1")
; (command "leader" arcpick2 pause "" (strcat "length = " arclen " Ft. "))
(command "_.text" "s" "note" "c" arcpick2 (getvar "textsize") "nea" "0" (strcat "AL=" arclen "'"))
(setq ent (entlast))
(setq elist (entget ent))
(setq oldwid (assoc 41 elist))
(setq newwid (cons 41 0.75))
(setq elist (subst newwid oldwid elist))
(entmod elist)
(command "_.rotate" "l" "" arcpick2 "nea" pause)
(command "_.move" "l" "" arcpick2 "non" pause)
)
(T
(princ "\n**Selected object must be an arc.**"))
)
(setvar "cmdecho" xcmdecho)
(setvar "snapmode" snp)
(setvar "orthomode" ortho)
(setvar "osmode" os)
(command "_.undo" "_end")
(princ)
)
You will need to get rid of the hard returns that I didn't put in.
Keep in touch
Bill Deshawn
http://my.sterling.net/~bdeshawn