Author Topic: DXF group code for ARC  (Read 2752 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
DXF group code for ARC
« on: November 30, 2004, 11:23:12 PM »
hi all,

Ok, now i have this question
How can i get the start point and the end point of an ARC ?

I've made this for a line and it work well when selecting a LINE.
but doesn't when selecting an ARC.

Maybe i've have the wrong DXF group code.. :oops:



(setq pi_sel1 (entsel "\n select a line :"))
  (setq pi_sel (entget (car pi_sel1)))
 
(setq wray_f1 (cdr (assoc 10 pi_sel)))
(setq wray_f2 (cdr (assoc 11 pi_sel)))

(vl-cmdf "text"  wray_f1 "" "" "Point 1" "")
(vl-cmdf "text"  wray_f2 "" "" "Point 2" "")


any help will be appreciated.

thanks.
Keep smile...

David Bethel

  • Swamp Rat
  • Posts: 656
DXF group code for ARC
« Reply #1 on: December 01, 2004, 08:08:56 AM »
Here's an old 1 all about ARC entities.  -David

Code: [Select]
;;|GET THE ARC DATA FROM 1 SELECTED ARC |;
(defun arc_data (/ olderr ss en ed et ha la lt tk ls ac uc
                   ce ra sa ea p1 p2 cd ca ia mc ch al wa aa mp)

;;;AREA OF A TRIANGLE
  (defun area-triangle (p1 p2 p3 / p4)
    (setq p4 (polar p3 (+ (angle p1 p2) (* pi 0.5)) 1))
    (* 0.5 (distance p1 p2)
           (distance p3 (inters p1 p2 p3 p4 nil))))

;;;MINIMAL ERROR CHECKING
  (setq olderr *error*
       *error* (lambda (e) (princ (strcat e "\t")) (setq *error* olderr) (princ)))

;;;GET 1 ARC ENTITY
  (while (or (not ss)
             (> (sslength ss) 1))
         (princ "\nSelect 1 ARC Entity")
         (setq ss (ssget '((0 . "ARC")))))

;;;GET ENTITY DATA
  (setq en (ssname ss 0)
        ed (entget en)
        et (cdr (assoc  0 ed))              ;entity type
        ha (cdr (assoc  5 ed))              ;handle
        lt (cdr (assoc  6 ed))              ;linetype
        la (cdr (assoc  8 ed))              ;layer
        tk (cdr (assoc 39 ed))              ;thickness
        ls (cdr (assoc 48 ed))              ;lt scale
        ac (cdr (assoc 62 ed))              ;color
        uc (cdr (assoc 210 ed))             ;ucs
        ce (cdr (assoc 10 ed))              ;center
        ra (cdr (assoc 40 ed))              ;radius
        sa (cdr (assoc 50 ed))              ;start angle
        ea (cdr (assoc 51 ed))              ;end angle
        p1 (polar ce sa ra)                 ;start point
        p2 (polar ce ea ra)                 ;end point
        cd (distance p1 p2)                 ;chord distance
        ca (angle p1 p2)                    ;chord angle
        mc (mapcar '(lambda (a b) (* (+ a b) 0.5)) p1 p2)
                                            ;mid point of chord
        ch (- ra (distance ce mc))          ;chord height
        ia (if (> ea sa)
               (- ea sa)
               (+ ea (- (* pi 2) sa)))      ;included angle
        mp (polar ce (+ sa (* 0.5 ia)) ra)  ;arc mid point
        al (* pi (* ra 2) (/ ia (* pi 2)))) ;arc length
    (and (> ia pi)                          ;for > 180 ARC
         (setq wa (* pi (* ra ra) (/ ia (* pi 2)))  ;wedge area
               aa (- wa (area-triangle ce p1 p2)))) ;area of chord_arc

   (initget "Yes No")
   (if (= "Yes" (getkword "\nShow Data <N>:   "))
      (progn
        (defun r_just (s p)
          (princ "\n")
          (repeat (- p (strlen s))
                  (princ " "))
          (princ s))
        (textpage)
        (r_just "Entity Name <-1>: " 30)
        (prin1 en)
        (r_just "Entity Type  <0>: " 30)
        (princ et)
        (r_just "Handle  <5>: " 30)
        (cond ((not ha)     (princ "HANDLES Disabled"))
              (T            (princ ha)))
        (r_just "LineType  <6>: " 30)
        (cond ((not lt)     (princ "BYLAYER"))
              (T            (princ lt)))
        (r_just "Layer  <8>: " 30)
        (princ la)
        (r_just "Center <10>: " 30)
        (prin1 ce)
        (r_just "Entity Color <62>: " 30)
        (cond ((not ac)         (princ "BYLAYER"))
              ((zerop ac)       (princ "BYBLOCK"))
              (T                (prin1 ac)))
        (r_just "Thickness <39>: " 30)
        (cond ((not tk)     (princ "0"))
              (T            (prin1 tk)))
        (r_just "LineType Scale <48>: " 30)
        (cond ((not ls)     (princ "1"))
              (T            (prin1 ls)))
        (r_just "Radius <40>: " 30)
        (prin1 ra)
        (r_just "Start Angle In Degrees <50>: " 30)
        (princ (angtos sa 0))
        (r_just "End Angle In Degrees <51>: " 30)
        (princ (angtos ea 0))
        (r_just "UCS <210>: " 30)
        (if (equal uc '(0 0 1) 1e-14)
            (princ "WORLD")
            (prin1 uc))
        (r_just "Start Point: " 30)
        (prin1 p1)
        (r_just "Arc Mid Point: " 30)
        (prin1 mp)
        (r_just "End Point: " 30)
        (prin1 p2)
        (r_just "ARC Length: " 30)
        (prin1 al)
        (r_just "Included Angle In Degrees: " 30)
        (princ (angtos ia 0))
        (r_just "Chord Length: " 30)
        (prin1 cd)
        (r_just "Chord Mid Point: " 30)
        (prin1 mc)
        (r_just "Chord Height: " 30)
        (prin1 ch)
        (r_just "Chord Angle Decimal: " 30)
        (princ (angtos ca))
        (r_just "Chord Angle Surveyors: " 30)
        (princ (angtos ca 4 4))))

;;;RESET *ERROR* & EXIT
   (setq *error* olderr)
   (princ))

;;;COMMAND LINE
(defun c:ad () (arc_data) (prin1))
R12 Dos - A2K

Andrea

  • Water Moccasin
  • Posts: 2372
DXF group code for ARC
« Reply #2 on: December 01, 2004, 11:32:43 AM »
Hey David...



Thank you very much.

 :wink:
Keep smile...