I've worked with all of the comments here over the last few days, and I appreciate all of the help you are offering. I wasn't able to convert the C# code to VB.NET, but I did try to glean some bits I recognized. What I understand is that I need to open the block definition itself (not the block reference) to get at the information about line segments nested within the block. I have opened the Block Table for read and for the block that is being iterated, opened the Block Table Record, trying to get at the entities within the block definition. Not working. I'm sure it is some convoluted misunderstanding on my part of the relationship between Block Reference, Block Table, Block Table Record, Block Definition and Entities. Can someone please straighten me out in a way that clarifies what seems to me to be a very serpentine set of relationships. I apologize up front for not already being an expert at this; in our department I'm actually the one who knows most about it. Sad, right? Anyway...
I've chopped out the bit of the program which is the crux of what I'm trying to do. The formatting didn't copy over from Visual Studio into this form. So items are not tabbed over the way the are in the real code. Sorry...
Where it's getting hung up is "For Each myEntity As Entity In myBTR"
It says "Value of ...ObjectID cannot be converted to ...Entity
So, how do I get at entities within a block definition to assess what layer they are on? The Block Table Record is the block definition, isn't it?
Any help is greatly appreciated. Thank you all so much.
'See if the block contains an Entity Code attribute
'See if the block contains an BayZone attribute; this includes nearest column zone (grid zone)
Dim EntityCode AsInteger= 0
Dim BAYZ AsInteger= 0
Dim myCount AsInteger
ForEach myAttRef As AttRef In GetAttributes(BRefID)
If myAttRef.attTag.ToString = "ENTITY_CODE" Then
EntityCode = 1
'In the block definition for this block, see how many lines are on layer "A-EQPM-FDPL"
'Open Block Table for Read; Done above...
'Open Block Table Record for Read
Dim acObjID As ObjectId
Dim myBTR As BlockTableRecord = myTrans.GetObject(acObjID, OpenMode.ForRead)
'Count how many line segments are on Layer "A-EQPM-FDPL"
'Look at each entity in the block definition and assess whether it is on the target layer
'No nested blocks; just look in top level block definition
myCount = 0
ForEach myEntity As Entity In myBTR
If myEntity.Layer.Contains("A-EQPM-FDPL") Then
myCount = myCount + 1
EndIf
Next
ElseIf myAttRef.attTag.ToString = "BAY_ZONE"Then
BAYZ = 1
EndIf
Next