CaveMan Posted February 9, 2012 Posted February 9, 2012 Good Day Have a Drawing that has symbol blocks in it. Blocks are not inserted into drawing - so no instances. How does one view the list of blocks in the current drawing. Any assistance welcome "This is probably a basic routine" Thanks in Advance Quote
fixo Posted February 9, 2012 Posted February 9, 2012 Try this function You can put DataSource property of ListBox as result of this function: Public Function ListBlocks() As List(Of String) Dim db As Database = HostApplicationServices.WorkingDatabase Dim blocks As New List(Of String) Try Dim tr As Transaction = db.TransactionManager.StartTransaction() Using tr Dim bt As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable) For Each id As ObjectId In bt Dim btr As BlockTableRecord = DirectCast(tr.GetObject(id, OpenMode.ForRead), BlockTableRecord) If Not btr.IsAnonymous And Not btr.IsLayout Then blocks.Add(btr.Name) End If Next End Using Catch ex As System.Exception Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(ex.Message & vbCr & ex.StackTrace) Return Nothing End Try Return blocks End Function On load in your form: ListBox1.DataSource=ListBlocks Not tested ~'J'~ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.