+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Full Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2015
    Posts
    50

    Default Counting Blocks Within a Boundary

    Registered forum members do not see this ad.

    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
    Last edited by Beeftimer; 14th Jan 2015 at 06:59 pm.

  2. #2
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    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/showth...in-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.

  3. #3
    Full Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2015
    Posts
    50

    Default

    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

  4. #4
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    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.

  5. #5
    Full Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2015
    Posts
    50

    Default

    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

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,892

    Default

    Just change *text to Insert and try this

    Code:
    ; 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
    A man who never made mistakes never made anything

  7. #7
    Full Member
    Using
    AutoCAD 2013
    Join Date
    Jan 2015
    Posts
    50

    Default

    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

  8. #8
    Super Member lamensterms's Avatar
    Computer Details
    lamensterms's Computer Details
    Operating System:
    Windows 7 - 64bit
    Discipline
    Manufacture
    lamensterms's Discipline Details
    Occupation
    Steel Detailer
    Discipline
    Manufacture
    Details
    3D Modelling - Mechanical & Structural 2D Detailing - Shop Drawings
    Using
    AutoCAD 2014
    Join Date
    May 2011
    Location
    Berwick, VIC, Australia
    Posts
    569

    Default

    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.

  9. #9
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO 64-bit
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x64
    CPU:
    Pentium(R) i5 4570 @ 3.2GHz
    RAM:
    8 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    2x ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2011
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    11,819

    Default

    Registered forum members do not see this ad.

    I moved your thread to the AutoLISP, Visual LISP & DCL Forum.
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



Similar Threads

  1. Counting Blocks
    By Michaels in forum AutoLISP, Visual LISP & DCL
    Replies: 33
    Last Post: 24th Aug 2010, 09:39 pm
  2. Counting Blocks
    By jagape in forum AutoCAD General
    Replies: 8
    Last Post: 9th Jun 2009, 11:37 pm
  3. Counting Blocks
    By jagape in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 26th Feb 2008, 08:00 pm
  4. counting blocks using ATTEXT
    By explorer in forum AutoCAD Drawing Management & Output
    Replies: 9
    Last Post: 19th Jul 2007, 05:05 pm
  5. counting the blocks, how will i add new column...?
    By madaryl in forum AutoCAD General
    Replies: 2
    Last Post: 1st Mar 2006, 04:10 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts