Ament Posted July 3, 2018 Posted July 3, 2018 Hello together, me again and this time with a question which I can't solve logically.. I guess I do not see the forest for the trees. I have a loop in which I use LeeMacs burst command (thank you for that briliant piece of code!). I' counting the number of blocks before the burst and afterwards and run my loop as long as the numbers are not equal. But somehow it doesn't leave the loop when they are equal. Please find the piece of code below: (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOB (sslength AllBlocks)) (setq NOBN 0) (while (/= NOB NOBN) (setq NOB (sslength AllBlocks)) (if (/= NOB 0) (LM:burst AllBlocks) ) (setq AllBlocks nil) (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOBN (sslength AllBlocks)) ) My thinking was that as soon as the Burst can't explode any block anymore NOB and NOBN will be equal and I'll go on with the remaining code. Also if there is no block anymore the burst is not called both values are 0 and the lisp goes on. Can someone tell me where I made the misstake? Best regards, Ament Quote
rlx Posted July 3, 2018 Posted July 3, 2018 assuming NOB is 10 for example and NOBN starts with 0 , on what moment / how will NOBN ever reach 10? where is (setq NOBN (1+ NOBN)) Quote
Solitechcadsolutions Posted July 3, 2018 Posted July 3, 2018 add in (if (= nob nobn) (exit)) it may work? Quote
rlx Posted July 3, 2018 Posted July 3, 2018 if your selectionset can contain nested blocks and that's the reason you want to loop until no block is left alive maybe this would do? : (while (setq ss (ssget "_X" (list (cons 0 "INSERT"))))(LM:burst ss)) Quote
BIGAL Posted July 3, 2018 Posted July 3, 2018 Also need to look at what other peoples code is doing LM:burst expects a selection set so no need to keep passing. Its now 3 lines with autoload lee-mac burst use Rlx code if you have nested blocks as suggested. (if (not LM:burst) (load "BurstUpgradedV1-4")) (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (LM:burst Allblocks ) Rlx snuck in while I was thinking about it. Quote
rlx Posted July 3, 2018 Posted July 3, 2018 Rlx snuck in while I was thinking about it. Sorry Bigal , didn't mean to snuck in (?) sneak up to you Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 @rlx NOBN will be equal to NOB if there is no block exploded during the loop. It is not a loop to repeat something eg. 10 times. / Unfortunately I have blocks left which can't be exploded even if I set all blocks to be explodeable before using (vlax-for b (vla-get-Blocks (vla-get-activedocument (vlax-get-acad-object))) (or (wcmatch (vla-get-Name b) "'**_Space*") (vla-put-explodable b :vlax-true))) @Solitechcadsolutions: If I'm not wrong it terminates my whole lisp. But I need it to go ahead after the loop is done. Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 Give me a few seconds to prepare it so that I can share it. I can't give you the whole one. Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 So, done. Please find the file below. Example.dwg Thank you for your time! Quote
rlx Posted July 3, 2018 Posted July 3, 2018 So, done. Please find the file below. [ATTACH]64123[/ATTACH] Thank you for your time! Had a very quick look and my first (educated) guess would be some blocks are non uniformly scaled (so x / y / z scale in the properties pallet are different). When you try to (manually) explode them you get : Command: x EXPLODE 1 found 1 was not able to be exploded. Sure there are links on how to handle non uniformly blocks here is one : http://www.cadtutor.net/forum/showthread.php?43266-Explode-a-Non-Uniformly-Scaled-Block Quote
rlx Posted July 3, 2018 Posted July 3, 2018 and for my second (educated) guess , mother block contains blocks with no name (anonymous blocks) Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 Hm, the first remark should be covered by LeeMacs Burst. At least he mention it in the description. I'm not good enough yet to go through his code and understand it ^^ Second remark. Not sure what I can do against it. It is a delivery from an external partner and it's the best I get. We try to improve there layouts quiet a while, but we don't have direct access to them. It would be really useful if there is a way to bypass it. Quote
rlx Posted July 3, 2018 Posted July 3, 2018 Block name that popped up after I exploded a chair was "*E" so maybe explode all normal blocks and then select all anonymous block and deport them... btw it seems to be a wipeout when you have a look at the block in the blockeditor Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 I would like to do so. Unfortunately some normal blocks are left after I used LM:Burst. Otherwise I would run it and deport all remaining blocks. Or is there a way to make a selection set for only anonymus blocks? Quote
rlx Posted July 3, 2018 Posted July 3, 2018 I would like to do so. Unfortunately some normal blocks are left after I used LM:Burst. Otherwise I would run it and deport all remaining blocks. Or is there a way to make a selection set for only anonymus blocks? search 'visual lisp select anonymous blocks' and maybe this one is useful : http://www.lee-mac.com/getanonymousreferences.html first run Lm:burst and after that ssget something like (ssget "x" '((2 . "`**"))) Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 Hm, some question came into my mind.. why can't I explode anonymous blocks? And after I managed to remane them (Even I'm able to open them in block editor now) why am I still not able to explode them? I even run through all of them again to set (vla-put-explodable b :vlax-true). EDIT: Oh I see, still they are unequaly scaled.. next task is how to set these values correctly using a lisp Oh and still the major question was: Why doesn't my while loop ends. Even If there are blocks left, as soon as the amount before the LM:Burst is equal to the amount of blocks after running it, it should leave the loop and just ignore the remaining blocks. But somehow it doesn't stop even if the parameter NOB and NOBN are showing the same value after I left the lisp using ESC-key. Quote
dlanorh Posted July 3, 2018 Posted July 3, 2018 Hello together, me again and this time with a question which I can't solve logically.. I guess I do not see the forest for the trees. I have a loop in which I use LeeMacs burst command (thank you for that briliant piece of code!). I' counting the number of blocks before the burst and afterwards and run my loop as long as the numbers are not equal. But somehow it doesn't leave the loop when they are equal. Please find the piece of code below: (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOB (sslength AllBlocks)) (setq NOBN 0) (while (/= NOB NOBN) (setq NOB (sslength AllBlocks)) (if (/= NOB 0) (LM:burst AllBlocks) ) (setq AllBlocks nil) (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOBN (sslength AllBlocks)) ) My thinking was that as soon as the Burst can't explode any block anymore NOB and NOBN will be equal and I'll go on with the remaining code. Also if there is no block anymore the burst is not called both values are 0 and the lisp goes on. Can someone tell me where I made the misstake? Best regards, Ament Try (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOBN 0) (while (/= (setq NOB (sslength AllBlocks)) NOBN) (if (/= NOB 0) (LM:burst AllBlocks) ) (setq AllBlocks nil) (setq AllBlocks (ssget "_X" (list (cons 0 "INSERT")))) (setq NOBN (sslength AllBlocks)) ) Quote
Ament Posted July 3, 2018 Author Posted July 3, 2018 @dlanorh: Maybe I have a slight misunderstanding, but doesn't it evaluate NOBN at the end of the first loop, and than evaluating NOB before starting next round using the exact same selection set? In that case of course both variables will be identical after first run isn't it? @all: I just tried a bit more and was quet surprised, because I found out that after each run on LM:burst the number of blocks in the drawing was increased.. It looks like as soon as the code is not able to burst any block anymore it starts multiplying it. Can someone confirm? 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.