finding a block by blockname

finding a block by blockname

Anonymous
Not applicable
278 Views
5 Replies
Message 1 of 6

finding a block by blockname

Anonymous
Not applicable
Can i find a block with blockname, without creating a selection set of all
object and search for a block and then the specific blockname. With a big
drawing this will take to much time.

Please give me advise

Thanks
Ysbrand Haagsma
The Netherlands
0 Likes
279 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
On Error Resume Next
Set MyBlock = ThisDrawing.Blocks.Item(BlockName)
If MyBlock Is Nothing Then (block was not found) Else (block was found)

I haven't checked the syntax...

--
Rune Wold
System Analyst
Engineering Systems
rune@engsys.no
--

"Ysbrand Haagsma" wrote in message
news:3C99B163870210F9BFAC333A21BC1A71@in.WebX.maYIadrTaRb...
> Can i find a block with blockname, without creating a selection set of all
> object and search for a block and then the specific blockname. With a big
> drawing this will take to much time.
>
> Please give me advise
>
> Thanks
> Ysbrand Haagsma
> The Netherlands
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
With this command i can't read the attributes for specific block. The syntax
does work, but does only connect to the blocks list anf not blocks on the
drawing.



> On Error Resume Next
> Set MyBlock = ThisDrawing.Blocks.Item(BlockName)
> If MyBlock Is Nothing Then (block was not found) Else (block was found)
>
> I haven't checked the syntax...
>
> --
> Rune Wold
> System Analyst
> Engineering Systems
> rune@engsys.no
> --
>
> "Ysbrand Haagsma" wrote in message
> news:3C99B163870210F9BFAC333A21BC1A71@in.WebX.maYIadrTaRb...
> > Can i find a block with blockname, without creating a selection set of
all
> > object and search for a block and then the specific blockname. With a
big
> > drawing this will take to much time.
> >
> > Please give me advise
> >
> > Thanks
> > Ysbrand Haagsma
> > The Netherlands
> >
> >
>
>
0 Likes
Message 4 of 6

Anonymous
Not applicable
The code I wrote will find the block, or the block definition. What you want
is the block reference.

You could check whether it's quicker to loop through the items in modelspace
(assuming, of course, that the block references you are looking for are in
modelspace).

Dim entBlk As AcadEntity
For Each entBlk In ThisDrawing.ModelSpace
If TypeOf entBlk Is AcadBlockReference Then
If entBlk.Name = "MyBlockName" Then MsgBox "Found block reference"
End If
Next

--
Rune Wold
System Analyst
Engineering Systems
rune@engsys.no
--
0 Likes
Message 5 of 6

Anonymous
Not applicable
thanx,
This is working fast.
i made first a selection set of al objects and looped through the selection
set. but this is working faster.


"Rune Wold" wrote in message
news:734FA6F72CF68A13386ACB782793B8DD@in.WebX.maYIadrTaRb...
> The code I wrote will find the block, or the block definition. What you
want
> is the block reference.
>
> You could check whether it's quicker to loop through the items in
modelspace
> (assuming, of course, that the block references you are looking for are in
> modelspace).
>
> Dim entBlk As AcadEntity
> For Each entBlk In ThisDrawing.ModelSpace
> If TypeOf entBlk Is AcadBlockReference Then
> If entBlk.Name = "MyBlockName" Then MsgBox "Found block reference"
> End If
> Next
>
> --
> Rune Wold
> System Analyst
> Engineering Systems
> rune@engsys.no
> --
>
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
Looping over every entity seems wasteful, you can create a selection set containing only blocks with a certain name using Filters. Refer to the attached file. This also filters out to blocks with attributes.
0 Likes