Author Topic: isolate/turnoff blocks  (Read 5753 times)

0 Members and 1 Guest are viewing this topic.

GISDUDE

  • Guest
isolate/turnoff blocks
« on: August 10, 2012, 12:30:02 PM »
Hey all,
Is there a small LISP file that may be out there to turn off a block? The problem I have is that I frequently get CAD drawings from other firms' that have their own blocks, but I would like to be able to turn off the blocks. The issue is that the the layers the blocks were created on - the block will still be visible b/c the layer is still visible.

My gut feeling is you'll say - explode blocks and put them on one layer. That is a lot of blocks to explode!

Many thanks, - BTW I'm on bricscad 12.2

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: isolate/turnoff blocks
« Reply #1 on: August 10, 2012, 02:31:18 PM »
Does Bricscad 12.2 have the ISOLATEOBJECTS command?

If not, try this simple program to toggle the DXF Visibility flag:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:showit ( / i s )
  2.     (if (setq s (ssget "_X" '((60 . 1))))
  3.         (repeat (setq i (sslength s))
  4.             (_substdxf 60 0 (entget (ssname s (setq i (1- i)))))
  5.         )
  6.     )
  7.     (princ)
  8. )
  9.  
  10. (defun c:hideit ( / i s )
  11.     (if (setq s (ssget "_:L"))
  12.         (repeat (setq i (sslength s))
  13.             (_substdxf 60 1 (entget (ssname s (setq i (1- i)))))
  14.         )
  15.     )
  16.     (princ)
  17. )
  18.  
  19. (defun _substdxf ( key value elst / pair )
  20.     (if (setq pair (assoc key elst))
  21.         (entmod (subst (cons key value) pair elst))
  22.         (entmod (append elst (list (cons key value))))
  23.     )
  24. )

The above should work for all objects, not just blocks.

GISDUDE

  • Guest
Re: isolate/turnoff blocks
« Reply #2 on: August 12, 2012, 01:02:53 AM »
Lee,
Thanks for the reply.
1) Bricscad doesn't have the ISOLATEOBJECTS command. Bummer, b/c I think that would've solved the problem fairly quickly.

2) Bricscad doesn't have a DXF VISIBILITY FLAG, either. However, the little code snippet you posted did work out tremendsously. My supervisor is a LISP guy and he kinda showed me how to execute this particular code. One thing though, why couldn't there be a way to explode those PARTICULAR BLOCKS (in this case there were 62), and then turn off those layers? I'm assuming this is probably 2 or 3 more steps in a LISP script?

Thanks again, that was definitely a bonus.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: isolate/turnoff blocks
« Reply #3 on: August 12, 2012, 04:16:33 AM »
Hi Lee .

When the variable pair would return nil to go to the else option in if function into your sub-routine _substdxf ?

Thanks

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: isolate/turnoff blocks
« Reply #4 on: August 12, 2012, 04:52:17 AM »
@ GISDUDE:
The fact that Lee's code works proves that Bricscad does have a dxf visibility flag!
But I would strongly advise against using this method. Invisible objects can, obviously, be very confusing both for other users and for you yourself in the future. Why don't you put the inserts on a dedicated layer and FREEZE that layer?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: isolate/turnoff blocks
« Reply #5 on: August 12, 2012, 04:55:48 AM »
Hi Lee .

When the variable pair would return nil to go to the else option in if function into your sub-routine _substdxf ?

Thanks

With the 62 DXF group for example, when the entity color is ByLayer.
Speaking English as a French Frog

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: isolate/turnoff blocks
« Reply #6 on: August 12, 2012, 05:05:41 AM »
Hi Lee .

When the variable pair would return nil to go to the else option in if function into your sub-routine _substdxf ?

Thanks

With the 62 DXF group for example, when the entity color is ByLayer.

Hi gile .

I think Lee used the DXF Visibility flag and not the 62 dxf for color !
Thanks

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: isolate/turnoff blocks
« Reply #7 on: August 12, 2012, 05:16:39 AM »
Hi Lee .

When the variable pair would return nil to go to the else option in if function into your sub-routine _substdxf ?

Thanks

With the 62 DXF group for example, when the entity color is ByLayer.

Hi gile .

I think Lee used the DXF Visibility flag and not the 62 dxf for color !
Thanks

Yes but I think the _substdxf is a 'generic purpose function' not directly related to this subject.
Speaking English as a French Frog

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: isolate/turnoff blocks
« Reply #8 on: August 12, 2012, 05:27:26 AM »
Yes but I think the _substdxf is a 'generic purpose function' not directly related to this subject.

Now it is clear , thank you so much Gile .  :-)


Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: isolate/turnoff blocks
« Reply #9 on: August 12, 2012, 09:40:12 AM »
Lee,
Thanks for the reply.

You're welcome :)

1) Bricscad doesn't have the ISOLATEOBJECTS command. Bummer, b/c I think that would've solved the problem fairly quickly.

I thought this suggestion might be a long shot since the ISOLATEOBJECTS command is new to AutoCAD 2012, but it was worth a try.

2) Bricscad doesn't have a DXF VISIBILITY FLAG, either. However, the little code snippet you posted did work out tremendsously.

As roy_043 correctly states, the fact that my code works for you would indicate that entities in Bricscad do indeed use the DXF Group 60 Visibility flag.

One thing though, why couldn't there be a way to explode those PARTICULAR BLOCKS (in this case there were 62), and then turn off those layers? I'm assuming this is probably 2 or 3 more steps in a LISP script?

I'm assuming that you cannot simply turn off the layers of the objects constituting the block as there are other objects residing on those layers which should be visible?

When the variable pair would return nil to go to the else option in if function into your sub-routine _substdxf ?

As far as I know, the DXF Group 60 code (visibility flag) will not be present if the object is visible (60 . 0), in the same way that Group 62 will not be present for ByLayer, as gile has posted.