Jump to content
Beeftimer

Counting Blocks Within a Boundary

Recommended Posts

Beeftimer

Hello, all. I have a question concerning block counting. I have become familiar with the BCOUNT command, but I wanted to take it one step further for my particular application.

 

What I have is several viewports within a drawing. Each viewport represents a particular floor of a building. Furthermore, within each floor are "loops" defined by colored, dashed lines in which there reside certain devices (blocks). Identical devices may exist within other loops on the same floor.

 

Here's the question: Is there a way to count (and possibly export that data to a spreadsheet) the number of blocks that reside within each loop boundary? The boundaries are rarely simply rectangles. It's easy to count the number of blocks within a viewport, but I'm having trouble figuring out (if there even IS a way) how to count the number of blocks within my loop boundaries.

 

**I should clarify and say that, when I say viewports, what I really mean is layouts. There is one viewport per layout/floor. Sorry if this caused any confusion or cringing.

 

Thanks in advance.

 

Beef

Edited by Beeftimer

Share this post


Link to post
Share on other sites
lamensterms

Hi Beef,

 

As far as selecting blocks within a loop/closed polyline - may I suggest the rountine in post #2 of this thread... http://www.cadtutor.net/forum/showthread.php?11682-Selecting-objects-within-a-polyline&

 

Here is a great LISP routine (by Lee Mac) that counts blocks with the option to export to a CSV file (can also insert a table/schedule into your drawing. http://www.lee-mac.com/blockcounter.html

 

Use these routines in conjunction and you should be all set.

Share this post


Link to post
Share on other sites
Beeftimer

Thank you, Lamensterms. This looks perfect! I've never used scripting in AutoCAD before. Can you tell me, is this C programming language?

 

*EDIT*

 

Also, is there not a way to use the DATAEXTRACTION command (that already exists) in conjunction with this script?

 

Beef

Share this post


Link to post
Share on other sites
lamensterms

These are both LISP programs. They can be loaded via the Tools menu > Load Applications...

 

There is a whole forum here at CadTutor dedicated to LISP. Some very helpful folk with some very handy solutions to problems.

Share this post


Link to post
Share on other sites
Beeftimer

Ah, so it's a programming language all on its own. Interesting. I'll have to look into this more closely. Thank you so much for your help.

 

Beef

Share this post


Link to post
Share on other sites
BIGAL

Just change *text to Insert and try this

 

; get text with closed pline example
(defun getcoords (ent)
 (vlax-safearray->list
   (vlax-variant-value
     (vlax-get-property
   (vlax-ename->vla-object ent)
   "Coordinates"
     )
   )
 )
)

(defun co-ords2xy (/ xy)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 2))
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy))
(setq I (+ I 2))
)
)
; program starts here
(setq plist (ssget (list (cons 0 "lwpolyline"))))
(setq numb (sslength plist))
(setq J 0)
(repeat numb
(setq co-ords (getcoords (ssname plist J)))
(co-ords2xy)
(setq ss (ssget "WP" co-ordsxy (list (cons 0 "*text")))) ; selection set of text within polygon
(princ (sslength ss)) ; this is howmany texts etc 
(setq co-ordsxy nil)
(setq J (+ J 1))
(setq ss nil)
) ; end repeat

Share this post


Link to post
Share on other sites
Beeftimer

BIGAL,

 

The code that lamensterms directed me to works pretty well, but I definitely appreciate your input. Maybe I'll try this one too and see what the difference is. It might help me to understand the language.

 

Thanks!

Beef

Share this post


Link to post
Share on other sites
lamensterms

Hi again Beef, it would be pretty easy to bring these two routines together into one command. That is something I would be happy to help you with. My knowledge of LISP is pretty limited, but it can be quite easy to build a good routine, combining a few different routines. Good luck and please let me know how you go.

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...