list blocks

list blocks

Anonymous
Not applicable
261 Views
7 Replies
Message 1 of 8

list blocks

Anonymous
Not applicable
Hi, I would like to cycle through all of the blocks in a drawing
and then check to see which ones have attributes.

how do I go about this

thanks in advance

MICK
0 Likes
262 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Dim blkDef As AcadBlock

For Each blkDef In ThisDrawing.Blocks
If blkDef.HasAttributes Then

End If
Next

Fair warning: it's possible for GetAttributes to return zip even when
HasAttributes returns True. This is because of a difference in their
implementations: HasAttributes considers all attributes in a block, even
constant attributes. GetAttributes, on the other hand, only works with
editable attributes.

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"mick_and_rosie" wrote in message
news:4B418767D69F7199391D9E625BF0F828@in.WebX.maYIadrTaRb...
> Hi, I would like to cycle through all of the blocks in a drawing
> and then check to see which ones have attributes.
>
> how do I go about this
>
> thanks in advance
>
> MICK
>
0 Likes
Message 3 of 8

Anonymous
Not applicable
Actually, I gave you a bum steer. The GetAttributes method is in the
AcadBlockReference class, not AcadBlock. Use the block's Items collection
and check each object using the TypeOf operator:

Dim blkDef As AcadBlock, subEnt As AcadEntity

For Each blkDef In ThisDrawing.Blocks
For Each subEnt In blkDef
If TypeOf subEnt Is AcadAttributeDefinition Then

End If
Next
Next

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph
0 Likes
Message 4 of 8

Anonymous
Not applicable
Hi Frank, I tried your code and I get the following error message
"Compile error
user defined type not defined"
and the following code is highlighted "TypeOf subEnt Is
AcadAttributeDefinition"

what am I doing wrong
PS I am using R2000

MICK

Frank Oquendo wrote in message
news:1C0B04A224EAE6F081DBDE0D68581BC4@in.WebX.maYIadrTaRb...
> Actually, I gave you a bum steer. The GetAttributes method is in the
> AcadBlockReference class, not AcadBlock. Use the block's Items collection
> and check each object using the TypeOf operator:
>
> Dim blkDef As AcadBlock, subEnt As AcadEntity
>
> For Each blkDef In ThisDrawing.Blocks
> For Each subEnt In blkDef
> If TypeOf subEnt Is AcadAttributeDefinition Then
>
> End If
> Next
> Next
>
> --
> http://www.acadx.com
> Win an autographed copy of
> "Mastering AutoCAD 2000 Objects"
> by Dietmar Rudolph
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
That would be bum steer #2. The Object Browser says the correct type is
AcadAttribute, not AcadAttributeDefinition.

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"mick_and_rosie" wrote in message
news:C4B0B6971D50D41750964997108E4BA1@in.WebX.maYIadrTaRb...
> Hi Frank, I tried your code and I get the following error message
> "Compile error
> user defined type not defined"
> and the following code is highlighted "TypeOf subEnt Is
> AcadAttributeDefinition"
>
> what am I doing wrong
> PS I am using R2000
>
> MICK
0 Likes
Message 6 of 8

Anonymous
Not applicable
thanks Frank that works fine. one more question if I may
once I have found a block with attributes I want to check for a particular
tag
how do I do that.

thanks again

MICK

Frank Oquendo wrote in message
news:04A7920BBFD72F2F207C83FD7339ED80@in.WebX.maYIadrTaRb...
> That would be bum steer #2. The Object Browser says the correct type is
> AcadAttribute, not AcadAttributeDefinition.
>
> --
> http://www.acadx.com
> Win an autographed copy of
> "Mastering AutoCAD 2000 Objects"
> by Dietmar Rudolph
>
> "mick_and_rosie" wrote in message
> news:C4B0B6971D50D41750964997108E4BA1@in.WebX.maYIadrTaRb...
> > Hi Frank, I tried your code and I get the following error message
> > "Compile error
> > user defined type not defined"
> > and the following code is highlighted "TypeOf subEnt Is
> > AcadAttributeDefinition"
> >
> > what am I doing wrong
> > PS I am using R2000
> >
> > MICK
>
0 Likes
Message 7 of 8

Anonymous
Not applicable
For Each blkDef In ThisDrawing.Blocks
For Each subEnt In blkDef
If TypeOf subEnt Is AcadAttribute Then
If subEnt.TagString = Then

End If
End If
Next
Next

--
http://www.acadx.com
Win an autographed copy of
"Mastering AutoCAD 2000 Objects"
by Dietmar Rudolph

"mick_and_rosie" wrote in message
news:C50BFF8DA86322FAA3F2B577BFA2FDBF@in.WebX.maYIadrTaRb...
> thanks Frank that works fine. one more question if I may
> once I have found a block with attributes I want to check for a particular
> tag
> how do I do that.
>
> thanks again
>
> MICK
0 Likes
Message 8 of 8

Anonymous
Not applicable
thanks again Frank that works great

MICK
0 Likes