.NET

Reply
New Member
2 Posts
0 Kudos
Registered: ‎07-10-2006
Post 1 of 2

determine the layer the block is on?

71 Views, 1 Replies
07-10-2006 02:14 PM
This is the code I have:

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()

Dim id As ObjectId
Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
For Each id In bt
Dim oName As String = CType(trans.GetObject(id, OpenMode.ForRead), BlockTableRecord).Name
Dim _block As BlockTableRecord = CType(trans.GetObject(id, OpenMode.ForRead), BlockTableRecord)
Next

_block.Name.ToString() will give me the name of the block but is there a way to determine what layer that block is on?
*Norman Yuan
Post 2 of 2

Re: determine the layer the block is on?

07-13-2006 08:19 AM in reply to: javi-e
-block in your code is a BlockTableRecord object, which is just a block
definition, not a block (BlockReference) inserted onto a drawing, so, it
does not lie on any layer (of course the entities that are part of the block
definition are on layer(s)).

Are you actually asking a block reference that is the reference to _block?
If so, it could be on any layer, and a BlockTableRecord may have many
BlockReferences on different layers.

wrote in message news:5232351@discussion.autodesk.com...
This is the code I have:

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()

Dim id As ObjectId
Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId,
OpenMode.ForRead), BlockTable)
For Each id In bt
Dim oName As String = CType(trans.GetObject(id,
OpenMode.ForRead), BlockTableRecord).Name
Dim _block As BlockTableRecord = CType(trans.GetObject(id,
OpenMode.ForRead), BlockTableRecord)
Next

_block.Name.ToString() will give me the name of the block but is there a way
to determine what layer that block is on?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!