Author Topic: Accessing Nested Blocks directly ~ Possible ?  (Read 1023 times)

0 Members and 1 Guest are viewing this topic.

hendie

  • Guest
Accessing Nested Blocks directly ~ Possible ?
« on: November 08, 2007, 07:13:23 AM »
Is there a way in VB, VB(a) or even in Lisp, but preferably VB) to access a nested block directly by name ?

Scenario: I have a number of blocks, all with unique names, and in those blocks are a number of nested blocks. The nested blocks have common names.
Say for example, I want to flip the visibility of the nested blocks. Currently I am looping through the block collection, finding the parent block, then looping through each entity, checking if it is a block reference, if it is, I check the name and if it's the right nested block, I flip the visibility.
This takes quite a while on large drawings and I wondered if there was a way somehow, given that I know all the block names to dive in straight to the nested block without having to iterate through entities.

Bryco

  • Water Moccasin
  • Posts: 1849
Re: Accessing Nested Blocks directly ~ Possible ?
« Reply #1 on: November 08, 2007, 07:47:56 AM »
I doubt it.
But if you know the name of the parent block then you don't need to loop through  the blocks.
Make an array of the block names and cycle through those
Set B=blocks(sarray(i))
set Br=b(3)  if 3 is the position that the blockref holds in the block

hendie

  • Guest
Re: Accessing Nested Blocks directly ~ Possible ?
« Reply #2 on: November 08, 2007, 08:40:47 AM »
that's what I thought but it was worth checking. Thanks

Dave R

  • Guest
Re: Accessing Nested Blocks directly ~ Possible ?
« Reply #3 on: November 09, 2007, 07:52:59 AM »
You could shorten the process somewhat by making a selection set of all the block references in the drawing and just looping through those instead of every entity in the drawing.

hendie

  • Guest
Re: Accessing Nested Blocks directly ~ Possible ?
« Reply #4 on: November 12, 2007, 03:27:08 AM »
That is actually what I am doing... I just didn't explain myself properly in my initial post, sorry.