titoprax Posted September 9, 2010 Posted September 9, 2010 Hi I would like to know if you can automatically answer the following two questions ... How to get the total length of lines or layers differentiated by style. By using acadiso.lin I have created various styles of lines, the idea would be to know the total length of each custom line existing in a drawing. How to know the number of blocks that are in a drawing automatically. Would I know the amount automatically if I remove or copy a block? Is there any way to find this out if it is not possible to do this automatically? Quote
ReMark Posted September 9, 2010 Posted September 9, 2010 Re: Block count. Have you looked at the BCOUNT command in Express Tools? BCOUNT Counts, itemizes, and displays in tabular form, the number of insertions of each block in the selected objects or in the entire drawing. By the way, it is not necessary, nor is it recommended that forum members double post. It just confuses things down the road. Thanks. Quote
migs Posted September 9, 2010 Posted September 9, 2010 for the 1st question you could try http://www.cadtutor.net/forum/showthread.php?42734-Line-Length-Calculator and 2nd, does the BCOUNT command not do this already? it gives the name and quantity of that block in the drawing and the total amount of blocks altogether in the drawing Quote
David Bethel Posted September 9, 2010 Posted September 9, 2010 For the line lengths, I'd try something like this: [b][color=BLACK]([/color][/b]defun c:llen [b][color=FUCHSIA]([/color][/b]/ lay lin i dt ss en ed di dt[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not lay[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]or [b][color=BLUE]([/color][/b]wcmatch lay [color=#2f4f4f]"*`**"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]wcmatch lay [color=#2f4f4f]"*`,*"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]tblsearch [color=#2f4f4f]"LAYER"[/color] lay[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq lay [b][color=MAROON]([/color][/b]strcase [b][color=GREEN]([/color][/b]getstring [color=#2f4f4f]"\nLAyer To Calulate: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not lin[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]or [b][color=BLUE]([/color][/b]wcmatch lin [color=#2f4f4f]"*`**"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]wcmatch lin [color=#2f4f4f]"*`,*"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]tblsearch [color=#2f4f4f]"LTYPE"[/color] lin[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq lin [b][color=MAROON]([/color][/b]strcase [b][color=GREEN]([/color][/b]getstring [color=#2f4f4f]"\nLType To Calulate: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq i -1 dt 0 ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 6 lin[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 8 lay[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss [b][color=BLUE]([/color][/b]setq i [b][color=RED]([/color][/b]1+ i[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b] di [b][color=GREEN]([/color][/b]distance [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 11 ed[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] dt [b][color=GREEN]([/color][/b]+ di dt[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]princ [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"\nTotal Length Of LINEs on LAyer "[/color] lay [color=#2f4f4f]" With LType "[/color] lin [color=#2f4f4f]" = "[/color] [b][color=GREEN]([/color][/b]rtos dt 2 4[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]zerop dt[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]alert [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"No Entities Match The Criteria\n"[/color] [color=#2f4f4f]"LAyer "[/color] lay [color=#2f4f4f]" - "[/color] [color=#2f4f4f]"LTYPE "[/color] lin[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
ReMark Posted September 9, 2010 Posted September 9, 2010 OK..now we have two threads with the exact same question going which is what we try to avoid here. migs: I suggested BCOUNT in the other post by the OP. Quote
titoprax Posted September 9, 2010 Author Posted September 9, 2010 Ok, sorry. I know the command Bcount, but my question is whether it is possible to count blocks automatically, either by using a table, Reactor, etc.. Quote
Tharwat Posted September 9, 2010 Posted September 9, 2010 Here is mine for counting Blocks in a drawing , I have just made it for you. (defun c:THblk (/ ss ents) ;Tharwat 09.Septmber.2010 (if (and (setq ss (ssget "_x" '((0 . "INSERT")) )) (setq ents (sslength ss))) (if (cond ( (= ents 1) (alert (strcat " You have only" " " (itoa ents) " " " Block ...") ) ) ( (> ents 1) (alert (strcat " You have" " " (itoa ents) " " " Blocks ...")) ) ) (princ) ) (alert " *** NO BLOCKS FOUND *** ") ) (princ) ) Regards, Tharwat Quote
migs Posted September 9, 2010 Posted September 9, 2010 ReMark: I never noticed your other post regarding the BCOUNT command or else i would have referred him there instead Quote
ReMark Posted September 9, 2010 Posted September 9, 2010 Well it looks like this will become the defacto main post so I guess my argument is mute. My apologies. Quote
fuccaro Posted September 9, 2010 Posted September 9, 2010 I merged the two threads into this one. Titoprax, please post a question only once. Quote
Lee Mac Posted September 9, 2010 Posted September 9, 2010 Search for Upgraded BCount, and Line Length Calculator, I believe someone has already provided a link for the latter. Quote
alanjt Posted September 9, 2010 Posted September 9, 2010 http://www.cadtutor.net/forum/showthread.php?52249-need-lisp-to-calculate-lengths-of-layers 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.