提取CAD图形中所有图块名称

时间:2024-02-24 13:33:08
Dim doc As ApplicationServices.Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument

        Using Tr As DatabaseServices.Transaction = doc.Database.TransactionManager.StartTransaction()
            Using bt As DatabaseServices.BlockTable = CType(Tr.GetObject(doc.Database.BlockTableId, DatabaseServices.OpenMode.ForRead), DatabaseServices.BlockTable)
                For Each id As ObjectId In bt
                    Dim btr As BlockTableRecord = CType(Tr.GetObject(id, DatabaseServices.OpenMode.ForRead), DatabaseServices.BlockTableRecord)
                    If Not btr.IsAnonymous AndAlso Not btr.IsLayout Then
                        ComboBox1.Items.Add(btr.Name)
                    End If
                Next
            End Using
        End Using