Lisp to count polyline verticies
Lisp to count polyline verticies
(OP)
Can anyone suggest a lisp that counts the number of verticies in a polyline or lwpolyline?
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS Come Join Us!Are you an
Engineering professional? Join Eng-Tips Forums!
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting GuidelinesJobs |
Lisp to count polyline verticies
|
RE: Lisp to count polyline verticies
If polyline is closed it will count that as an extra vertex. It could be fixed with a check of the "closed flag" if you need it.
CODE
(vl-load-com)
(setq Pl_Ent (car (entsel "\nSelect polyline: ")))
(setq VL_Obj (vlax-ename->vla-object Pl_Ent))
(setq endParam (vlax-curve-getEndParam Vl_Obj))
(setq NumVert (+ 1 endParam))
(princ (strcat "\n" (rtos NumVert 2 0) " vertices"))
(princ)
)
RE: Lisp to count polyline verticies
RE: Lisp to count polyline verticies
You might change the "c:nvert" since it does more now.
CODE
;;for a single polyline. And maybe a few other objects
(defun c:nvert ()
(vl-load-com)
(setq Pl_Ent (car (entsel "\nSelect polyline: ")))
(setq VL_Obj (vlax-ename->vla-object Pl_Ent))
(setq endParam (vlax-curve-getEndParam Vl_Obj))
(setq NumVert (+ 1 endParam))
(setq Pl_Len (vlax-curve-getDistAtParam VL_Obj endParam))
(princ (strcat "\n" (rtos NumVert 2 0) " vertices"))
(princ (strcat "\nLength= " (rtos Pl_Len)))
(princ)
)
RE: Lisp to count polyline verticies
RE: Lisp to count polyline verticies
Good place to start (& maybe all you'll need) is http://www.afralisp.net/