Author Topic: Arc Midpt  (Read 2458 times)

0 Members and 1 Guest are viewing this topic.

DanB

  • Bull Frog
  • Posts: 366
Arc Midpt
« on: March 14, 2005, 01:12:03 PM »
Can anyone help me with determining the Midpoint of a selected arc. Currently I am able to extract the center point with:

Code: [Select]

    (setq ent (entsel "\nSelect ARC: "))
    (setq arc_list (entget (car ent))             ; entity list
          cpt (cdr (assoc 10 arc_list))           ; center point


Is there a similar format for the midpoint as well?

Thanks

Jeff_M

  • King Gator
  • Posts: 4042
  • C3D user & customizer
Arc Midpt
« Reply #1 on: March 14, 2005, 01:43:39 PM »
No, but here's a few useful functions put to use:
Code: [Select]

(setq crv (car (entsel "\nSelect ARC: ")))
(setq startPt (vlax-curve-getstartpoint crv)
        endPt (vlax-curve-getendpoint crv)
        len (vlax-curve-getdistatpoint crv endPt)
        midPt (vlax-curve-getpointatdist crv (/ len 2))
      )

daron

  • Guest
Arc Midpt
« Reply #2 on: March 14, 2005, 02:53:29 PM »
For a dxf version I wrote this a long time ago, but as you can see, the VL version is easier and smaller. (Partial code)
Code: [Select]
(setq ent1   (ssname ss cnt)
elist1 (entget ent1)
etype1 (strcase (cdr (assoc 0 elist1)) 1)
ssl    (sslength ss)
ent    (ssname ss cnt)
elist  (entget ent)
rad    (cdr (assoc 40 elist))
cen    (trans (cdr (assoc 10 elist)) 0 1)
ang1   (cdr (assoc 50 elist))
ang2   (cdr (assoc 51 elist))
delta  (- ang2 ang1)
cnt    (1+ cnt)
 ) ;_ setq
 (if (minusp delta)
      (setq delta (+ delta (* pi 2)))
 ) ;_ if
 (setq pt1   (polar cen ang1 rad)
pt2   (polar cen ang2 rad)
alen  (* rad delta)
hdelt (/ delta 2)
pt3   (polar cen (+ hdelt ang1) rad)
rang  (angtos (angle pt1 pt2))
alens (rtos (/ alen 12) 2 2)
)

DanB

  • Bull Frog
  • Posts: 366
Arc Midpt
« Reply #3 on: March 15, 2005, 07:39:11 AM »
Thanks, I'll try these out.

Dan

SMadsen

  • Guest
Arc Midpt
« Reply #4 on: March 15, 2005, 08:00:49 AM »
Or, a simple but slightly less secure solution:
Code: [Select]

(osnap (polar (cdr (assoc 10 entl))(cdr (assoc 51 entl))
              (cdr (assoc 40 entl)))
       "mid"
)

entl being the arc_list in your example