arc length

Discussion in 'AutoCAD' started by Dees, Mar 26, 2006.

  1. Dees

    Dees Guest

    How would one find the length of an arc using autolisp?
     
    Dees, Mar 26, 2006
    #1
  2. I think you need to calculate it using the object data, which is
    Radius(group code 40) and Start Angle and End Angle(group code 50).
     
    Michael Bulatovich, Mar 26, 2006
    #2
  3. Dees

    bestafor Guest

    HiHo;
    Here is a old one you can use the parts.
    ;CADENCE Magazine February 1992
    ;Page 86



    ;Note: Calculate arc length, included angle, chord, and radius
    ;en = entity name
    ;ed = entity definition
    ;et = entity type
    ;r = radius
    ;p1 = end pt of arc at start angle
    ;p2 = end pt of arc at end angle
    ;c = chord length
    ;cb = chord bearing
    ;sa = start angle
    ;ea = ending angle
    ;a = included angle
    ;al = arc length
    ;ctr = center point
    ;answer1 = arc length, included angle, and radius
    ;answer2 = chord length and bearing
    ;--------------------
    (defun c:ArcLIST
    (/ i en ed et r p1 p2 c cb sa ea a al ctr answer1 answer2)
    ;-----clear user input-----
    (setq i 1)
    (while i
    (setq en (car (entsel "\nPick an arc: ")))
    (if en
    (progn
    (setq ed (entget en))
    (setq et (cdr (assoc 0 ed)))
    (if (/= et "ARC")
    (prompt "\nEntity is not an arc.")
    (setq i nil)
    );if
    );progn
    (prompt "\nYou did not pick anything.")
    );if
    );while
    ;-----retrieve relevant data-----
    (setq ctr (cdr (assoc 10 ed)))
    (setq r (cdr (assoc 40 ed)))
    (setq sa (cdr (assoc 50 ed)))
    (setq ea (cdr (assoc 51 ed)))
    (setq p1 (polar ctr sa r))
    (setq p2 (polar ctr ea r))
    (setq c (distance p1 p2)) ;chord length
    (setq cb (angle p1 p2)) ;chord bearing
    ;-----calculate included angle-----
    (if (< sa ea)
    (progn
    (setq ea (- ea sa))
    (setq sa (- sa sa))
    (setq a ea)
    )
    (progn
    (setq sa (- sa ea))
    (setq ea (- ea ea))
    (setq a (abs (- sa (* 2 pi))))
    )
    );if
    ;-----calculate arc length-----
    (setq al (/ (* pi r a) pi)) ;arc length
    (terpri)
    (setq answer1
    (strcat "Arc length = " (rtos al)
    " Included angle = " (angtos a 0)
    " Radius = " (rtos r)
    )
    );setq
    (setq answer2
    (strcat "Chord length = " (rtos c)
    " Chord bearing = " (angtos cb)
    )
    );setq
    (prompt answer1)
    (terpri)
    (prompt answer2)
    (princ)
    );defun
     
    bestafor, Mar 26, 2006
    #3
  4. Dees

    Dees Guest

    Thanks, I think I can make that work for what I am doing.
    Happy Autolisping
     
    Dees, Mar 27, 2006
    #4
  5. Dees

    Brian Salt Guest

    This is one lisp available:

    ;|

    DIMARC.LSP - Dimension an arc with length, rather than angle
    (c) 1998 Tee Square Graphics

    |;

    (defun C:DIMARC (/ arc ent obj l)
    (setq cmd (getvar "cmdecho")
    arc (entsel "\nPick ARC to dimension: ")
    ent (entget (car arc))
    obj (cdr (assoc 0 ent)))
    (if (= obj "ARC")
    (progn
    (setvar "cmdecho" 1)
    (setq l (* (cdr (assoc 40 ent))
    (if (minusp (setq l (- (cdr (assoc 51 ent))
    (cdr (assoc 50 ent)))))
    (+ pi pi l) l)))
    (command "_.dimangular" arc "_t" (rtos l))
    (while (= (logand (getvar "cmdactive") 1) 1)
    (command pause))
    (setvar "cmdecho" cmd))
    (alert "Object selected is not an ARC."))
    (princ)
    )
     
    Brian Salt, Mar 27, 2006
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.