- Dim PtFormSQL As New Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0) '这是你从SQL中读取的坐标值
- Using Trans As Transaction = doc.TransactionManager.StartTransaction
- Dim BlkTab As BlockTable = Trans.GetObject(doc.Database.BlockTableId, OpenMode.ForRead)
- For Each ID As ObjectId In BlkTab
- Dim Ent As Entity = Trans.GetObject(ID, OpenMode.ForRead)
- If TypeOf Ent Is BlockReference Then
- Dim Blk As BlockReference = Ent
- Dim Pt As Autodesk.AutoCAD.Geometry.Point3d = Blk.Position
- If Blk.Name = "xxxx" AndAlso Pt.DistanceTo(PtFormSQL) <= 0.1 Then '距离根据实际情况确定
- '如果小于容差,就认为这个块你你想要的
- '要不要判断名称,看着办
- End If
- End If
- Next
- End Using
|