Author Topic: Pline distance w/ included arcs  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

brennon

  • Guest
Pline distance w/ included arcs
« on: November 15, 2004, 04:16:16 PM »
I am trying to write a lisp program that will enable me to get the distance of a polyline that has arcs in it.  

For example:  You need to get the distance between 2 points on a drawing and between those points are several straight lines and a few arcs.

I have a lisp program called distm, that I got from this site.  It doesn't say who created it, but it works great for getting the total distance of several individual lines, However it doesn't allow you to select arcs.

Is there a way to modify it so it will pick arcs?  If so, How?  Is there already a lisp routine that allows someone to pick straight and curved polylines?  

I am learning lisp still and don't quite fill comfortable enough to tackle the modifications myself.  But, if I had some guidance then I could definately modify it without dificulty.

The (distm) lisp routine is below:

(defun c:distm (/ dipt1 dipt2)
  (setq   FIRSTPT   (getpoint "Pick point ")
   dipt2   (getpoint FIRSTPT "\nNext point ")
   dx   (- (car dipt2) (car firstpt))
   dy   (- (cadr dipt2) (cadr firstpt))
   ang   (angle firstpt dipt2)
   distm   (distance firstpt dipt2)
  )
  (princ (strcat "\n\n  Distance is  "
       (rtos (distance firstpt dipt2))
       ",     "
    )
  )
  (princ
    (strcat "  Angle is  " (angtos ang 0 6) " Deg.,     ")
  )
  (princ (strcat "\n  Delta X is  " (rtos dx) ",     "))
  (princ (strcat "  Delta Y is  " (rtos dy) ",     "))
  (while (/= dipt2 nil)
    (setq dipt1 dipt2)
    (setq dipt2 (getpoint dipt1 "\n\nNext point "))
    (if   (/= dipt2 nil)
      (progn
   (setq distm (+ distm (distance dipt1 dipt2))
         dx    (- (car dipt2) (car dipt1))
         dy    (- (cadr dipt2) (cadr dipt1))
         ang   (angle dipt1 dipt2)
   )
   (princ (strcat "\n\n  Distance is  "
             (rtos (distance dipt1 dipt2))
             ",     "
          )
   )
   (princ
     (strcat "  Angle is  " (angtos ang 0 6) " Deg.,     ")
   )
   (princ (strcat "\n  Delta X is  " (rtos dx) ",     "))
   (princ (strcat "  Delta Y is  " (rtos dy) ",     "))
   (princ
     (strcat "\n  Running Total Distance is  " (rtos distm))
   )
      )
    )
  )
  (princ
    (strcat "\n\n                       Final Total Distance is  "
       (rtos distm)
    )
  )
  (princ)
)


Thanks for any help you can give me!! :D

PS.  However wrote this routine, it's great I use it everyday. CONGRATS!!


** edited Subject line MST **

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Pline distance w/ included arcs
« Reply #1 on: November 15, 2004, 05:19:17 PM »
Try this, author unknown.
Code: [Select]
(defun entLen (/ set:OfEnts int:l rea:LengthOfEnts)
  (setq set:OfEnts  (ssget)
        int:l 0
        rea:LengthOfEnts 0.0
  ) ;_ setq
  (while (< int:l (sslength set:OfEnts))
    (setq rea:LengthOfEnts
           (+ rea:LengthOfEnts
              (vlax-curve-getdistatparam
                (vlax-ename->vla-object (ssname set:OfEnts int:l))
                (vlax-curve-getendparam (ssname set:OfEnts int:l))
              ) ;_ vlax-curve-getDistAtParam
           ) ;_ +
    ) ;_ setq
    (setq int:l (1+ int:l))
  ) ;_ while
  (princ (strcat "\nEntities: - "
                 (itoa (sslength set:OfEnts))
                 "\nTotal Lengh: - "
                 (rtos rea:LengthOfEnts)
         ) ;_ strcat
  ) ;_ princ
  (prin1)
) ;_ defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

brennon

  • Guest
Pline distance w/ included arcs
« Reply #2 on: November 15, 2004, 05:35:41 PM »
Thanks CAB that lisp routine should work great!!

Brennon

whdjr

  • Guest
Pline distance w/ included arcs
« Reply #3 on: November 16, 2004, 01:59:41 PM »
Why not just get the length property of the polyline?

daron

  • Guest
Pline distance w/ included arcs
« Reply #4 on: November 16, 2004, 02:03:59 PM »
You could do that too, but those vlax-curve-parameters are sooooo much fun and way more flexible.

whdjr

  • Guest
Pline distance w/ included arcs
« Reply #5 on: November 16, 2004, 02:30:09 PM »
Quote from: Daron
You could do that too, but those vlax-curve-parameters are sooooo much fun and way more flexible.


What type of cheese you been eatin over there? :D