Couting Dynamic Blocks

Couting Dynamic Blocks

MikeKovacik4928
Advisor Advisor
1,301 Views
5 Replies
Message 1 of 6

Couting Dynamic Blocks

MikeKovacik4928
Advisor
Advisor

I would like to post this as a separate question. It was solved as part of another post, which was "annotation on attributes in blocks".

The main question still hasn't been solved, but this side issue was solved by John Vellek.

John, if you could post you answer here, I would like to close this issue with an "accept as solution"

 

Solution for my case was

 

Use the dataextraction command (this counts lookup and visibility states)

another suggested solution, which didn't work for my case, was using the DBcount lisp routine (this only counts visibility states)

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman/Designer
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa

0 Likes
Accepted solutions (1)
1,302 Views
5 Replies
Replies (5)
Message 2 of 6

john.vellek
Alumni
Alumni
Accepted solution

HI @MikeKovacik4928,

 

Just to add my two cents (which is frequently only worth one cent) I like to use data extraction to count the dynamic blocks. It will even let you count and sort by Visibility states.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 3 of 6

gpcattaneo
Advocate
Advocate

Try this... (press F2 to display results)

 

(defun c:dbcount ( / blks n blk bL bL+)

    (vl-load-com)

    (if (setq blks (ssget "_X" '((0 . "INSERT"))))
        (progn
            (repeat (setq n (sslength blks))
                (if (eq :vlax-true (vla-get-isdynamicblock (setq blk (vlax-ename->vla-object (ssname blks (setq n (1- n)))))))
                    (setq bL (acad_strlsort (cons (vla-get-effectivename blk) bL)))
                )
            )
            (setq bL (reverse bL))
            (while bL
                (if bL+
                    (setq bL+ (cons (cons (car bL) (length (vl-remove-if-not '(lambda (b) (eq b (car bL))) bL))) bL+))
                    (setq bL+ (list (cons (car bL) (length (vl-remove-if-not '(lambda (b) (eq b (car bL))) bL)))))
                )
                (setq bL (vl-remove-if '(lambda (b) (eq b (car bL))) bL))
            )
            (princ "\n ") (princ "\n ")
            (foreach x bL+
                (princ (strcat "\n  " (itoa (cdr x)) "  Dynamic Block: " (car x) ))
            )
        )
    )
    (princ)
)

 

0 Likes
Message 4 of 6

MikeKovacik4928
Advisor
Advisor

This routine doesn't seem to work.

 

I get the following message after using appload with your routine

 

Command: APPLOAD
dbcount.lsp successfully loaded.
Command: malformed list on input
Command:

 

See attached screenshots

 

I have also run another lisp which counts dynamic blocks but only their visibility states not lookup states.

This lisp uses the same command name as your lisp ie dbcount.

Not being a lisper I don't know whether that has anything to do with it.

Looking at the message I don't think so, but am not really sure

 

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman/Designer
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa

 

0 Likes
Message 5 of 6

gpcattaneo
Advocate
Advocate

Work fine for me, try attached (renamed) file.

 

 

0 Likes
Message 6 of 6

MikeKovacik4928
Advisor
Advisor

okay

 

it works now (see 05 & 07)

Still doesn't do what I want it to do.(see 06)

Doesn't count the lookup states or visibility states

Dataextract is still the way to go for me (see 06)

 

 

Mike

 

0 Likes