.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 5
Anonymous
435 Views, 4 Replies

Block name

hi!
How can i know the name of a block?
I have a blockreference but i dont know how extract the name block!

thank!
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Open the ObjectId returned by the block reference's DynamicBlockTableRecord property, which gives you the BlockTableRecord, and read its Name property.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"Bux" wrote in message news:5882973@discussion.autodesk.com...
hi!
How can i know the name of a block?
I have a blockreference but i dont know how extract the name block!

thank!
Message 3 of 5
Anonymous
in reply to: Anonymous

Thanks Tony: now it work!
but can you tell me if it is a good way or is there a better way to extract
all attribute from blocks?


Dim AcadDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = AcadDoc.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Dim BT As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim BTR As BlockTableRecord = tr.GetObject(BT(BlockTableRecord.ModelSpace),
OpenMode.ForRead)
For Each id As ObjectId In BTR
Dim Obj As DBObject = tr.GetObject(id, OpenMode.ForRead)
If TypeOf Obj Is BlockReference Then
Dim BR As BlockReference = CType(Obj, BlockReference)
Dim myblocktablerecord As BlockTableRecord =
tr.GetObject(BR.BlockTableRecord, OpenMode.ForRead)
ed.WriteMessage(myblocktablerecord.Name & vbCrLf)
Dim attcol As AttributeCollection = BR.AttributeCollection
For Each idatt As ObjectId In attcol
Dim att As AttributeReference = tr.GetObject(idatt, OpenMode.ForRead)
ed.WriteMessage(att.Tag.ToString + " - " + att.TextString.ToString + vbCrLf)
Next
End If
Next
Message 4 of 5
artisteroi
in reply to: Anonymous

I wonder, can I use this same code to extract the block name if it is a null value? I am trying to get rid of the dwg file that a block came from but when it was inserted the block was assigned a name but the dwg file was not, so I cant purge it without a name. The picture expalins it.
Message 5 of 5
chris.j.mckeown
in reply to: Anonymous

How do you access the autocad database viewer?

Regards

Chris

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost