You are here:

AutoCAD/Arc-length from known radius & chord

Advertisement


Question
Hi,
I have a radius of 1326.0
And a chord of 72.0

How can I find the arch length using autolisp?

Answer
Dan:  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

AutoCAD

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill DeShawn

Expertise

I can address all 2-D questions and some 3-D questions. I do programming in AutoLISP if it doesn`t involve solid modeling. I can also address menu customization issues and can help you find answers to questions I can`t answer by taking your question directly to Autodesk via their newsgroups.

Experience

I used to do electronic and mechanical design for a flat panel monitor manufacturer, and now I do architectural drafting for an architect. I did and do AutoLISP and menu customization and take pride in making my lisp routines to do the work exactly the way the client likes them done.

Publications
I had a routine published in CADENCE magazine (no longer in publication and taken over by CADALYST). Some of my routines are published on my website at http://my.sterling.net/~bdeshawn

©2012 About.com, a part of The New York Times Company. All rights reserved.