Jump to content

Counting Blocks within a defined shape?


Recommended Posts

I have always wondered if it is possible to count blocks whos insertion point lies within a define shape.

 

Currently I am working on a large office layout with many floors and would like to keep track of numbers of seats as the layout evolves.

 

My currrent solution is to make a block (even if identical to other floors) for each floor, then I can just count how many of each block name exists.

 

This isn't the most elegant solution, and it means you have to be very careful that you have the correct block on the correct floor.

 

Any suggestions would be greatly appreciated.

 

I am keen to have a solution that works as far back and 2000, but if thats not possible its a fine reason to force and upgrade for slackers in my office.

 

Regards

 

Moo

Link to comment
Share on other sites

Try this, not a whole lot of testing

;;; Selection set of blocks inside polyline by ssget WP   divides curves into 16 sections for window  LPS 2010-05-14
(defun c:test (/ idx obj endparam cnt ss1)
(vl-load-com)
 (setq ptlst nil)
 (setq ss1 nil)
 (setq obj (vlax-ename->vla-object (car (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 section 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 jammie/Lee Mac
   (not
     (equal
           (angle '(0 0 0)
             (vlax-curve-getSecondDeriv obj (1- idx))) 0.0 1e-
     )
   (progn
     (setq cnt (1- idx))
     (repeat 15;divide curve
       (setq ptlst(cons (vlax-curve-getPointAtParam obj (+ cnt 0.0625)) ptlst)
             cnt (+ 0.0625 cnt))
       )
     )
   );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"))))
  (if (not (= ss1 nil))
 (alert (strcat "There are " (itoa (sslength ss1)) " blocks within the selected polyline"))
    (alert "No blocks")
    );if
 
  (princ)
 );defun

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...