Jump to content

Dynamic block counting!


CadFrank

Recommended Posts

Hi, i am looking to create a lisp program that will count my dynamic block name (visibility name). in my intire drawing. much as Quick select but for dynamic block!

Link to comment
Share on other sites

This isn't what im looking for ! i have like 10 different block in my dynamic block! they all have different name and i whant to select them according the name they have in the dynamic block to make a total of each.

Link to comment
Share on other sites

This isn't what im looking for !

 

Instead of being impolite, perhaps you can post the code you have so far, so we may see where you are getting stuck?

Link to comment
Share on other sites

I'm sorry i wasn't trying to be impolite and i have no code ! i only have autocad drawing with the blocks! im new at autolisp also just trying to learn! but basicly trying to find something that will work to improve my speed at counting!

 

There for i'm sorry if i sounded rude or impolite!

Link to comment
Share on other sites

I'm sorry i wasn't trying to be impolite and i have no code ! i only have autocad drawing with the blocks! im new at autolisp also just trying to learn! but basicly trying to find something that will work to improve my speed at counting!

 

There for i'm sorry if i sounded rude or impolite!

 

No worries :); something that would help us to know you're not being impolite is for you to NOT use the exclamation point "!" so much. This conveys an urgency, or tone which can easily be misunderstood. We have members from all over the world, so understanding each other can sometimes be a challenge.

 

I understand you're new to LISP, and some of these concepts may be well above your current skill level. Perhaps someone with more time will feel like donating their time to better help you.

 

That said, here's a quick summary of how I might approach this task:

 

Start by creating a selection set of dynamic blocks, the step through them one at a time to extract the current visibility state. Store a counter variable with the visibility state for that block to a grouped pair, for each visibility state returned from the dynamic blocks. Then send the count results for each block type (visibility state) with the count to the command line, or an alert dialog box.

 

Hope this helps!

Link to comment
Share on other sites

I have alot of dynamic block created. But since i can quick select them i cant count them fast

the only thing i can creat on lisp atm is defun c:HELLO ()

Kinda sad hehe

 

so im pretty much lost here ... i guess im to new at this.. would you know a place i could learn autolisp quick. i tried getting some tips from the afralisp site but theres so much to read.

Link to comment
Share on other sites

I do not have a dynamic block on which to test, but give this a try:

 

(defun c:BCD () (c:BlockCountDynamic))
(defun c:BlockCountDynamic  (/ ss dynProps item val valList i n)
 (vl-load-com)
 (princ "\rBLOCK COUNT: DYNAMIC ")
 (if (setq ss (ssget "_x"
                     (list '(0 . "INSERT")
                           '(2 . "`*U[color=red][color=black]*,[/color]<DynBlockName>[/color]")
                           (cons 410 (getvar 'ctab)))))
   (progn
     (vlax-for x  (setq ss (vla-get-activeselectionset
                             (vla-get-activedocument
                               (vlax-get-acad-object))))
       (if (and (= :vlax-true (vla-get-isdynamicblock x))
                (setq dynProps (vlax-invoke x 'getdynamicblockproperties)))
         (foreach prop  dynProps
           (if (and (vl-string-search
                      "VISIBILITY"
                      (strcase (vla-get-propertyname prop)))
                    (setq val (vlax-get prop 'value)))
             (if (setq item (assoc val valList))
               (setq valList
                      (subst (cons val (1+ (cdr item))) item valList))
               (setq valList (cons (cons val 1) valList)))))))
     (if valList
       (progn
         (textpage)
         (prompt "\n\nTotal: \t\t\tVisibility state: ")
         (foreach item  (vl-sort valList
                                 '(lambda (x y)
                                    (< (car x) (car y))))
           (prompt
             (strcat
               "\n  "
               (cond ((= 1 (setq i (strlen (setq n (rtos (cdr item) 2 0)))))
                         (strcat n "\t\t\t>>  "))
                     ((= 2 i) (strcat n "\t >>  "))
                     ((= 3 i) (strcat n "     >>  "))
                     ((= 4 i) (strcat n "    >>  "))
                     (T (strcat n "  >>  ")))
               (car item)))))
       (prompt "\n** No visibility states found ** "))
     (terpri)
     (vla-delete ss))
   (prompt "\n** Nothing selected ** "))
 (princ))

 

... If it is unsuccessful, please let me know what error message is shown at the command line, and post a copy of your dynamic block.

 

Hope this helps!

Edited by BlackBox
Code revised
Link to comment
Share on other sites

The code (above) has been revised.

 

I have tested it against the block you posted and all *seems* to be working on my end.

 

Screen shot:

 

CT_bcd.test.png

Edited by BlackBox
Link to comment
Share on other sites

Their's something weird happen the lisp work but it keep 1 of the block in mind

 

BLOCK COUNT: DYNAMIC

>> LU CADRE PLAN (2) 2'-6" Total = 3

>> LU CADRE PLAN (2) 5'-4" Total = 1

>> LU CADRE PLAN (2) 5'-4" Total = 4

 

in the drawing i have 4.

 

lets say i copy the block a few time and this is the counting it does!

i cant still manage to make it work like this i think.

 

it keep the one block i copied in mind even if i change it and counts the others aswell

Link to comment
Share on other sites

Sorry about that, I noticed that too (after the fact - Doh! :ouch:), but I *beleive* I have fixed, as the screen shot on my earlier post now shows.

 

Please try to revised code on the first page one more time... I do hope it works well. :unsure:

Link to comment
Share on other sites

Ok sry i wasnt seeing your new post im new at this forum.

 

Well it seems it works now properly thx to you.. a very big thank you!! only one other question.. if i have other dynamic block will it work or do i have to had something in the notepad

Link to comment
Share on other sites

Ok sry i wasnt seeing your new post im new at this forum.

 

Well it seems it works now properly thx to you.. a very big thank you!!

 

You're welcome, I'm glad I could help! :)

 

only one other question.. if i have other dynamic block will it work ...

 

... Here's where you give it a try for yourself, and let me know how it works. :wink:

Link to comment
Share on other sites

well we have a winner it works with different dynamic block!

 

well you just made me very happy!! and maybe you helped me get a raise :P because this will improve my productivity at work.

 

cheers to you!

Link to comment
Share on other sites

well we have a winner it works with different dynamic block!

 

That's great!

 

well you just made me very happy!! and maybe you helped me get a raise :P because this will improve my productivity at work.

 

cheers to you!

 

... Sooooo... I can expect a check in the mail then!? 2funny.gif LoL (

 

Cheers! :beer:

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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