Author Topic: Counting blocks within a polyline  (Read 2699 times)

0 Members and 1 Guest are viewing this topic.

grush

  • Guest
Counting blocks within a polyline
« on: June 09, 2010, 09:17:20 AM »
Does anybody have a lisp to count blocks within a selected polyline?
thanks...

pete

Gliderider

  • Guest
Re: Counting blocks within a polyline
« Reply #1 on: June 09, 2010, 10:17:25 AM »
it's raining...
Code: [Select]
;;; Count inserts within polyline  LPS 2010-06-09
(defun c:test (/ idx obj endparam ss1)
(vl-load-com)
  (setq ptlst nil)
  (setq ss1 nil)
  (setq obj (vlax-ename->vla-object (car (setq pl (entsel "\nSelect polyline boundary: ")))))
  (if (or; test if polyline and has area
(/= (vlax-get-property obj 'ObjectName) "AcDbPolyline")
(zerop (vlax-get-property obj 'Area))
)
    (princ "\nSelected entity is not a polyline or can not be used for a selection window")
    )

  (setq ptlst (list (vlax-curve-getStartPoint obj))
idx 1)
  (if (zerop (vlax-get obj 'Closed))
        (setq endparam (vlax-curve-getParamAtPoint obj (vlax-curve-getEndPoint obj)));if open param at end point
(setq endparam (cdr (assoc 90 (entget (vlax-vla-object->ename obj)))));if closed # vertices
    )
    
  (while
    (<= idx endparam)
      (if;test for curve - thanks to Lee Mac and others
(not
 (equal
            (angle '(0 0 0)
              (vlax-curve-getSecondDeriv obj (1- idx))) 0.0 1e-8)
 );not
(progn
 (setq cnt (1- idx))
 (repeat 15;divide curve
   (setq ptlst(cons (vlax-curve-getPointAtParam obj (+ cnt 0.0625)) ptlst)
         cnt (+ 0.0625 cnt))
   );repeat
 );progn
);if
   (setq ptlst (cons (vlax-curve-getPointAtParam obj idx) ptlst)
idx (1+ idx))
   );while
  (setq ptlst (reverse ptlst))
  (setq ss1  (ssget "_WP" ptlst '((0 . "INSERT"))))
  (princ (strcat "\nThe number of inserts within the polyline is " (itoa (setq ssnum (sslength ss1)))))
  (princ)
  );defun

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Counting blocks within a polyline
« Reply #2 on: June 09, 2010, 11:01:17 AM »
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

meja

  • Newt
  • Posts: 47
Re: Counting blocks within a polyline
« Reply #3 on: June 10, 2010, 09:26:16 AM »
the lisp is very useful :lol: