本帖最后由 作者 于 2009-2-12 23:04:54 编辑
给你个完整的代码: 功能为你选择一个圆,立即把这个圆创建为一个块,并把注释写入圆的圆心坐标和半径,然后显示该注释内容检验正确性,最后把该块插入到图纸中。 Sub ttttt() Dim ss As AcadSelectionSet Dim c(0 To 0) As AcadCircle Dim ent As AcadEntity Dim blockObj As AcadBlock Dim cc As Variant Dim r As Double Set ss = ThisDrawing.SelectionSets.Add("ssss") '在屏幕上选择对象 ss.SelectOnScreen For Each ent In ss If ent.ObjectName = "AcDbCircle" Then Set c(0) = ent cc = c(0).Center r = c(0).Radius GoTo aa End If Next MsgBox "你没有选择到任何圆形对象!" ss.Delete End aa: Set blockObj = ThisDrawing.Blocks.Add(cc, "圆形块") ThisDrawing.CopyObjects c, blockObj blockObj.Comments = "圆心:" & cc(0) & "," & cc(1) & "," & cc(2) & "," & " 半径:" & r MsgBox blockObj.Comments '显示块注释 ThisDrawing.ModelSpace.InsertBlock cc, "圆形块", 1, 1, 1, 0 '插入建立的块 ss.Delete End Sub |