Block count with attribute filter

Discussion in 'AutoCAD' started by Jason, Oct 20, 2003.

  1. Jason

    Jason Guest

    For the purposes of a council submission, I need to keep track of
    carparking spaces for the development I'm working on. Getting a total
    number of spaces is easy enough, but I need to filter out the various
    type of parks (standard, parents with prams, accessible, existing, and
    offsite parking).
    It would seem to me the easiest way of doing this would be to creat
    selection sets by filtering the overall selection via the value of a
    single attribute in the carpark symbol.
    Anyone done this type of thing before, and wish to share their
    knowledge and code examples? It would sure save me a lot of time.

    -Jason.
    v8_interceptor (at) hotmail.com
     
    Jason, Oct 20, 2003
    #1
  2. Jason

    bestafor Guest

    HiHo;
    ATTEXT or DDATTEXT will do.
    It's best to create a templet file
    simular to below
    ...........................................................
    BL:NAME C011000
    PT.NUM. N005000
    BL:X N012002
    BL:Y N012002
    
    .................................................
    The the cdf can be imported to excel or
    some other data base.
    A filter can be made (ssget "X" (list (cons 2 BLOCKNAME)))
    with the addition of the attributes you need.
     
    bestafor, Oct 21, 2003
    #2
  3. Is the attribute the only distinguishing thing about the various spaces?
    (They are the same block) If so I would use different blocks to allow FILTER
    to
    count them for me. If you do get a routine to do something like this for
    you,
    you might want to make sure it ignores identical copies of the blocks in
    the same place. You could end up with a erroneous count if you don't,
    and the number will be LOW which is usually NOT good.
    You could alternatively run a routine to identify/delete identical
    dopplegangers first.
     
    Michael Bulatovich, Oct 21, 2003
    #3
  4. Jason

    Randy Jones Guest

    If you use blocks with different names then you can BCOUNT them.
     
    Randy Jones, Oct 21, 2003
    #4
  5. Jason

    Jason Guest

    Whilst you're suggestions are appreciated, they weren't really the
    response I needed.
    Using different blocks and then BCOUNT'ing them will do the job, but
    is untidy.
    After some exhaustive searching, I actually found the code I was
    looking for.
    For the benfit of those to go after me, here it is.


    ;;; GETATTRIB
    *
    ;;; Pass an INSERT entity and see if any attribs correspond to atttag
    *
    ;;; If the passed attrib tag is found then return its value.
    *

    (defun getattrib (ent atttag / entl att f_att)
    (setq ent (entnext ent)) ; get next entity
    and check if it's an attribute
    (setq entl (entget ent))
    (while (= "ATTRIB" (cdr (assoc 0 entl)))
    (setq att (cdr (assoc 2 entl)))
    (if (= att atttag)
    (setq f_att (cdr (assoc 1 entl))) ; the attribute is
    of right type, retrieve it
    )
    (setq ent (entnext ent)
    entl (entget ent)
    )
    )
    f_att ; return value, or nil if not found
    )

    I believe it came from this newsgroup originally, but unfortunately I
    do not know who to credit it too.

    - Jason.
     
    Jason, Oct 23, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.