Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Summarizing all blocks by their name into a table or a list.

  1. #1
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Summarizing all blocks by their name into a table or a list.

    Can someone help me figure out a way to summarize all blocks located in active paper space by their names and then create (somewhere on the sheet) a summary list organized by block name and quantity of each block.

    I know how to organize all of the blocks into a selection set, but I am stuck after that...please help.

    Thank you

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Try this ...

    Code:
    (defun c:test (/ ss l)
      ;;	Tharwat 22. May. 2014		;;
      (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar 'CTAB)))))
        ((lambda (i / sn nm it)
           (while (setq sn (ssname ss (setq i (1+ i))))
             (if (setq it (assoc (setq nm (vla-get-effectivename
                                            (vlax-ename->vla-object sn)
                                          )
                                 )
                                 l
                          )
                 )
               (setq l (subst (list (car it) (1+ (cadr it))) it l))
               (setq l (cons (list nm 1) l))
             )
           )
         )
          -1
        )
      )
      (if l
        (progn
          (foreach x l
            (print x)
          )
          (textscr)
        )
      )
      (princ)
    )(vl-load-com)

  3. #3
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Wonderful, this code works...it prints to the screen, I'll just have to tweak the code to make it print a list or a table on the sheet somewhere in paper space.

    Thank you
    PS. Could you explain how this code works for newbies like myself.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Try this .

    Code:
    (defun c:Test (/ WriteAndSet columns e ss l hgt inc ins rows p r tbl)
      ;;	Tharwat 23. May. 2014		;;
      (if (setq ss (ssget "_X"
                          (list '(0 . "INSERT") (cons 410 (getvar 'CTAB)))
                   )
          )
        ((lambda (i / sn nm it)
           (while (setq sn (ssname ss (setq i (1+ i))))
             (if (setq it (assoc (setq nm (vla-get-effectivename
                                            (vlax-ename->vla-object sn)
                                          )
                                 )
                                 l
                          )
                 )
               (setq l (subst (list (car it) (1+ (cadr it))) it l))
               (setq l (cons (list nm 1) l))
             )
           )
         )
          -1
        )
      )
      (if l
        (progn
          (setq hgt
                 (if
                   (zerop
                     (cdr
                       (assoc
                         40
                         (setq
                           e (entget (tblobjname "STYLE" (getvar 'textstyle)))
                         )
                       )
                     )
                   )
                    (* (getvar 'textsize) 2.0)
                    (* (cdr (assoc 40 e)) 2.0)
                 )
                columns 2
                r 2
          )
          (if (setq ins (getpoint "\n Specify Table Location :"))
            (progn
              (setq
                tbl (vla-addtable
                      (vlax-get
                        (vla-get-activelayout
                          (vla-get-activedocument (vlax-get-acad-object))
                        )
                        'BLOCK
                      )
                      (vlax-3d-point ins)
                      (+ (length l) 2)
                      columns
                      (* hgt 1.5)
                      (* hgt 1.5)
                    )
              )
              (setq inc -1)
              (repeat 2
                (vla-setcolumnwidth tbl (setq inc (1+ inc)) (* hgt 5.))
              )
              (vla-setrowheight tbl 0 (* hgt 1.5))
              (vla-setrowheight tbl 1 (* hgt 1.5))
              (vla-settext
                tbl
                0
                0
                (strcat "Blocks Quantity")
              )
              (vla-setcolumnwidth tbl 0 (* hgt 10.))
              (vla-setcolumnwidth tbl 1 (* hgt 4.5))
              (vla-settext tbl 1 0 "Block Name")
              (vla-settext tbl 1 1 "QTY")
            )
          )
          (defun WriteAndSet (col row string)
            (vla-settext tbl row col string)
            (vla-setcellalignment tbl row col acMiddleCenter)
          )
          (foreach x l
            (WriteAndSet 0 r (car x))
            (WriteAndSet 1 r (cadr x))
            (setq r (1+ r))
          )
        )
      )
      (princ)
    )
    (vl-load-com)

  5. #5
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Do you think the same can be done by using MTEXT or TEXT instead of blocks?

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Do you think the same can be done by using MTEXT or TEXT instead of blocks?
    At the mean time , I can say yes but it depends on what you are after as long as you did not give enough information .

    Did not you try the last routine that I wrote just for you ?

  7. #7
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Oh yes I did and it works beautifully!!!!!
    ....sorry I forgot to update you.

    As I think more about this...I don't think text would be a good idea, so never mind about the text.

    Thank you very much for the routine...it works like a champ

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    Quote Originally Posted by vladimir.karatsupa982899 View Post
    Oh yes I did and it works beautifully!!!!!
    ....sorry I forgot to update you.

    As I think more about this...I don't think text would be a good idea, so never mind about the text.

    Thank you very much for the routine...it works like a champ
    Excellent , happy to hear that and you are welcome anytime .

  9. #9
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    I wanted to refine my selection set...and got the following:

    (setq ss (ssget "X" (list '(0 . "INSERT")(8 . "Units")(2 . "UNIT_*")(67 . 1)(cons 410 (getvar "CTab")))))

    Please take a look at it and advise why do I recieve an (error: bad argument type: consp "Units")

    When I do this...
    (setq ss (ssget "X" '((0 . "INSERT")(8 . "Units")(2 . "UNIT_*")(67 . 1)(cons 410 (getvar "CTab")))))
    I get (error: bad SSGET list)

  10. #10
    Member
    Join Date
    2006-07
    Location
    Currently Vancouver BC
    Posts
    47
    Login to Give a bone
    0

    Default Re: Summarizing all blocks by their name into a table or a list.

    you can't use use (cons... under quote '(


    '( means read AS IS

    In your case you will have to use (list

    (setq ss (ssget "X" (list '(0 . "INSERT")'(8 . "Units")'(2 . "UNIT_*")'(67 . 1)(cons 410 (getvar "CTab")))))

Page 1 of 2 12 LastLast

Similar Threads

  1. Sheet List Table
    By Steve Smith in forum AutoCAD Sheet Set Manager
    Replies: 9
    Last Post: 2014-06-30, 04:30 PM
  2. Table List for Non SS Drawings
    By CADdancer in forum AutoCAD Sheet Set Manager
    Replies: 1
    Last Post: 2010-01-29, 05:07 PM
  3. Replies: 1
    Last Post: 2006-12-12, 07:36 AM
  4. Replies: 1
    Last Post: 2006-10-13, 04:58 PM
  5. Sheet List Table
    By afortier in forum AutoCAD Sheet Set Manager
    Replies: 2
    Last Post: 2005-06-01, 10:40 AM

Posting Permissions

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