AutoCAD Electrical General Discussion

AutoCAD Electrical General Discussion

Reply
Active Contributor
kani_mca
Posts: 43
Registered: ‎02-07-2013
Message 1 of 2 (240 Views)

Block Name

240 Views, 1 Replies
02-13-2013 01:26 AM

 How to Get Block Name from Current drawing using vb.net?

 

Dim objEditor As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        Dim objDocument As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim objDatabase As Database = objEditor.Document.Database
        Dim symbolNames As String
        Using objTransaction As Transaction = objDatabase.TransactionManager.StartTransaction()
            Dim objBlockTable As BlockTable
            objBlockTable = TryCast(objTransaction.GetObject(objDatabase.BlockTableId, OpenMode.ForRead), BlockTable)

            Dim objBlockTableRecord As BlockTableRecord
            objBlockTableRecord = TryCast(objTransaction.GetObject(objBlockTable(BlockTableRecord.ModelSpace), OpenMode.ForRead), BlockTableRecord)
            For Each acObjId As ObjectId In objBlockTableRecord
                symbolNames = acObjId.ObjectClass.DxfName
            Next

        End Using

 

when Iam using the above code,I get all object name...but i did not get block name,instead of that i got "INSERT" as a Block name...I want to get Block name correctly...How to get it?

*Expert Elite*
rhesusminus
Posts: 921
Registered: ‎09-21-2007
Message 2 of 2 (178 Views)

Re: Block Name

02-26-2013 11:06 PM in reply to: kani_mca

Using this code, you are asking for the DXFNAME og the object class, wich is INSERT (i.e. a Block Reference).

You will have to check the Name-property of this block refrence for what you are looking for.

 


Trond Hasse Lie
ECAD Consultant
CtrlAltEl

Please select "Accept As Solution" if this post answers your question. Kudos don't hurt either. ;-)
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions to get help installing your software.

New AutoCAD Electrical Category!

The AutoCAD Electrical forum has moved into it's very own category page, and can no longer be found within the Additional Product Forums.

Announcements
Manufacturing Community
The Manufacturing Community provides additional access to tips, tutorials, blogs and networking with peers.