Author Topic: Getting all blocks in a drawing based on name.  (Read 8675 times)

0 Members and 1 Guest are viewing this topic.

BKSpurgeon

  • Mosquito
  • Posts: 6
Re: Getting all blocks in a drawing based on name.
« Reply #15 on: March 15, 2016, 10:32:48 PM »
Mr Blackbox / Gator

I feel the same thing when i read your code and answers.........how much more when i read Gilles and Tony's!


kiki

  • Mosquito
  • Posts: 7
Re: Getting all blocks in a drawing based on name.
« Reply #16 on: September 16, 2017, 04:00:57 PM »
Hi, I know this post is old, but I have problem I can't solve.

Is this any elegant way to get "top" layer listed nested blocks using GetBlockReferenceIds?
There is no problem to get real layer (br.Layer), but please see my sample drawing with nested blocks.

Using GetBlockReferenceIds and br.Layer, I receive following result:

Pos. / BlockName / LayerName
1. / Square / Layer1
2. / Circle / 0
3. / Arc / 0
4. / Square / 0
5. / Circle / 0
6. / Arc / 0

But I would like to achieve:

Pos. / BlockName / LayerName
1. / Square / Layer1
2. / Circle / Layer1
3. / Arc / Layer1
4. / Square / 0
5. / Circle / 0
6. / Arc / 0

I will be grateful for help.

Bryco

  • Water Moccasin
  • Posts: 1882
Re: Getting all blocks in a drawing based on name.
« Reply #17 on: September 17, 2017, 04:01:03 PM »
1) you have the layer from the blockref
2) iterate through the ents in the block and if they are on layer 0 -print the blockref layer.
3) if an ent in the iterationis a blockref-open its block and check it's entities layers

kiki

  • Mosquito
  • Posts: 7
Re: Getting all blocks in a drawing based on name.
« Reply #18 on: September 18, 2017, 02:07:11 PM »
Thank you for answer.

I have written iteration function which works well, but is very slow when I working with big drawings.

Therefore I try to improve it using GetBlockReferencesId collection. It is incredible fast for counting blocks, but I have to step back for "top" layer name when I have only nested ObjectId.
 

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: Getting all blocks in a drawing based on name.
« Reply #19 on: September 22, 2017, 07:17:50 PM »
every entity has a property OwnerId which is the block table record which owns it. You can call up the chain of ownership quite quickly this way to access the layer information of the containing block