CadFrank Posted July 22, 2011 Posted July 22, 2011 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! Quote
Lee Mac Posted July 22, 2011 Posted July 22, 2011 This includes Dynamic Blocks in the block count, but not by visibility state. Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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. Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 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? Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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! Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 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! Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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. Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 (edited) 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 July 26, 2011 by BlackBox Code revised Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 Hi so this is the error that it game me. Command: bcd BLOCK COUNT: DYNAMIC ; error: bad SSGET list value thx alot for your help. dynamic block.dwg Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 (edited) 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: Edited July 22, 2011 by BlackBox Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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 Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 Sorry about that, I noticed that too (after the fact - Doh! ), 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. Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 here is what get !! how do you prosses for your upload Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 I've just copied code from this post, and loaded it into this drawing: Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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 Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 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: Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 alright i will thx alot again ! and i'll try understanding your lisp some how. Quote
CadFrank Posted July 22, 2011 Author Posted July 22, 2011 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 because this will improve my productivity at work. cheers to you! Quote
BlackBox Posted July 22, 2011 Posted July 22, 2011 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 because this will improve my productivity at work. cheers to you! ... Sooooo... I can expect a check in the mail then!? LoL ( Cheers! Quote
Recommended Posts
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.