Identifying entities as blocks in an if loop

Identifying entities as blocks in an if loop

Anonymous
Not applicable
1,128 Views
2 Replies
Message 1 of 3

Identifying entities as blocks in an if loop

Anonymous
Not applicable

Hello, I have written a LISP script which, among other things, selects all objects and repeatedly bursts them until all entities are irreducible. This needs to happen in a while loop, so that after this task has been accomplished the script can move on to the next task automatically. Here is the portion of the script which wants to accomplish this:

 

Capture.PNG

This code runs an 'if' loop conditional on whether or not it finds an entity in the selection set "blocks" whose 0 attribute = INSERT, which as far as I can find seems to be the only way to determine whether or not an entity is a block. The issue I am running into is that in some drawings the 'if' loop seems still somehow to identify entities in the selection set as having a 0 attribute = INSERT, even though ALL of the blocks have already been burst. This interrupts the script since as soon as it tries to run the C:Burst command on the selection set with no blocks in it, the user is prompted to select burstable objects, of which there are none.

 

Is there some other more fool proof way to identify entities in a selection set as blocks? This error is telling me that an entity can have a 0 attribute = INSERT even if the entity is in fact not a block, or at any rate not burstable.

 

Thanks in advance!

0 Likes
Accepted solutions (1)
1,129 Views
2 Replies
Replies (2)
Message 2 of 3

SeeMSixty7
Advisor
Advisor
Accepted solution

While I don't recommend exploding all your blocks... 

 

you could utilize a while loop until there are no more INSERTS found

 

(while (setq myss (SSGET "X" '((0 . "INSERT"))))

      (... code to verify and burst blocks here)

)

 

You need to make sure that all blocks are defined as explodable though. and not on locked layers. XREFS will appear as INSERTS as well. You would need to prior to this build a list of XREFS and then exclude them from the ssget statement. (you could do that in a few ways (create a selection set of just the xrefs then remove from your selection set))

 

Good luck,

Message 3 of 3

Anonymous
Not applicable

This is a much better way to condition the 'while' loop. Works like a charm as long as I get rid of any stray XREFs and blocks running around in paper space. Thanks!